pack individual .jpg image files into RecordIO (.rec) files - python

I'm trying to go through the MXNET tutorial (https://statist-bhfz.github.io/cats_dogs_finetune), but have trouble making the RecordIO ".rec" files used to process the pictures.
I have tried the suggested approach:
python C:/mxnet-20170203/tools/im2rec.py --list=1 --recursive=1 --train-ratio=0.8 cats_dogs train_pad_224x224
python C:/mxnet-20170203/tools/im2rec.py --num-thread=4 --pass-through=1 cats_dogs_train.lst train_pad_224x224
python C:/mxnet-20170203/tools/im2rec.py --num-thread=4 --pass-through=1 cats_dogs_val.lst train_pad_224x224
But i get the error: "AttributeError: 'module' object has no attribute 'MXIndexedRecordIO'"
when doing so.
Is there a way to generate the ".rec" files in R directly? And if not, how do i get pass the error?
Thanks.
Kr,
Daniel

The error you are getting seems related to the fact that you are trying to use a newer version of im2rec.py than the one that came with your installed version of mxnet, hence the missing modules.
try using the im2rec.py script located in your own mxnet installation folder, somewhere like this python2.7/site-packages/mxnet/tools/im2rec.py
Also note that if you upgrade your version of mxnet, the syntax of im2rec has changed to:
im2rec.py --list --recursive --train-ratio=0.8 cats_dogs train_pad_224x224

Related

Cannot import eurostag.dll into Python

I am new with programming, so it is maybe harder for me to understand but I have the following issue:
I have a script that imports "eurostag.dll", which according to its manual, should work until Python 3.6. (but the manual is not updated, so it may work also with later updates, I assume).\ The issue is that I have Python 3.8. and when running the script I receive the following message:
"Failed to load EUROSTAG library (Could not find module 'D:\Eurostag\eustag_esg.dll' (or one of its dependencies). Try using the full path with constructor syntax.)"
I have tried to move the .dll library where the script is, but nothing changed. I tried also changing the directory with os.chdir, but the same message appears (with the same 'D:\Eurostag\eustag_esg.dll', so the directory was not changed.
Does anybody know if there is any workaround for this?
Thank you!

How to find the version of Spacy and python used in a pickle file?

I want to open the following pickle file that I dumped a few months ago, but I get the following error.
dataset_s = pickle.load(open("dataset_s.pickle",'rb'))
AttributeError: Can't get attribute 'cluster' on <module 'spacy.lang.lex_attrs' from ...
Also, when I want to import the packages that I used, I get the following warning.
DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in
the future. Please pass the result to `transformed_cell` argument and any exception
that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17
and above, and should_run_async(code)
Can someone help me resolve these issues?
If you are getting this file from Github, it is very likely that they have a file called requirements.txt where they describe the version requirements for packages.
Depending on the environment are you using, there are even different ways you can you can set up the environment to automatically update/reverse based on the requirements.txt:
Pycharm
Conda
Warning does not influence your current run, but it is best to change your code to be compatible with the future versions of the package according to it. Or you can also save the version information and reverse to older version package in the future.

Fixing broken django module that was installed from pip, where is the code?

I have been trying to use the django-visits module, though I seem to not even get this to run cause the minute I follow the instructions for just adding it to my application here:
https://bitbucket.org/jespino/django-visits/src/c3ac83b91969?at=default
It gives me an error when I try to run server:
ERRORS:
visits.Visit.ip_address: (fields.E900) IPAddressField has been removed
except for support in historical migrations.
HINT: Use GenericIPAddressField instead.
Their hint was helpful enough, but I have no idea where pip instaleld my django-visits to where I can change the model code of this module to fix the IPAdressField
Am I approaching solving this error wrong? Should I not be looking for the original code that was installed somewhere on my machine? Do I need to somehow install this from source and not use Pip since I have to change the models.py in this module?
(I am trying to make this work on my OS X machine but ultimately will need to get this to work on CentOS box). Also the database is postgres/postgis

cloudera-scm-agent fails when using python 2.7

Not sure how I can get around this...on the cloudera-manager site it says their software requires either pyhton2.6 or python2.7
however when i try to start the cloudera-scm-agent it complains that:
/opt/versioned_apps/cm-4.8.2/lib64/cmf/agent/build/env/bin/python: error while loading shared libraries: libpython2.6.so.1.0: cannot open shared object file: No such file or directory
I'm running centos7 (which is not supported out of the box).
To make matters worst, I don't know anything about python either (sorry)...so if i need to install anything, please provide step-by-step instructions :-)

python-opencv AttributeError: 'module' object has no attribute 'createBackgroundSubtractorGMG'

I am trying to follow the tutorial given in:
https://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_video/py_bg_subtraction/py_bg_subtraction.html
While trying the third example (BackgroundSubtractorGMG) I get this error:
AttributeError: 'module' object has no attribute 'createBackgroundSubtractorGMG'
I got the same error for the earlier examples. But I followed the explanation given in this post. some how, the same trick did not work here.
If there is some one who has managed to solve it, please help me out.
Using Python 2.7.3 & opencv 2.4.6.1 on Ubuntu 12.04
In OpenCV 3.0.0-dev, you have to compile with the contrib repos and then it's in the bgsegm sub-module. I.e. just call cv2.bgsegm.createBackgroundSubtractorGMG()
cv2.bgsegm.createBackgroundSubtractorGMG()
cv2.createBackgroundSubtractorMOG2()
cv2.bgsegm.createBackgroundSubtractorMOG(),
**this worked for me **
oh dear, that's another one of those stories ...
with 2.4.6, you only can use BackgroundSubtractorMOG from python. (full stop)
as of 2.4.8, it seems, the BackgroundSubtractorMOG2 problem got fixed, but the BackgroundSubtractorGMG is still missing.
with both versions, you use a plain constructor to create one.
in 3.0 (master), they changed the syntax, you now have to call 'createBackgroundSubtractorGMG', 'createBackgroundSubtractorMOG2' and such (that's what your tutorial might be refering to). but now you can use all 3 versions at least.
so in any way, if you want to use BackgroundSubtractorMOG2 , you'll have to update to 2.4.8, if you need BackgroundSubtractorGMG, you'll need 3.0 (which is 'bleeding edge' in a way, but the new interface has the far better control over the params needed, imho).
bgsegm was in contrib module of opencv, but after the update I am not sure.
But still,
if you have not built contrib module:
pip install opencv-contrib-python
Make sure no console is running that has imported cv2 while you execute your installing process.
Run the cmd as Administration
It worked for me.

Categories