Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with using command train #35

Open
Sean-Nolan6 opened this issue Jan 12, 2022 · 7 comments
Open

Problems with using command train #35

Sean-Nolan6 opened this issue Jan 12, 2022 · 7 comments

Comments

@Sean-Nolan6
Copy link

Hi
I am currently setting up Antrax on an Ubuntu 21.10. I am using conda as a virtual environment and have installed the Matlab python engine that came with Matlab R2019a. The issue I currently am having is that when using the command antrax train I am seeing an error of:

Traceback (most recent call last):
  File "/home/sean/anaconda3/envs/test/bin/antrax", line 8, in <module>
    sys.exit(main())
  File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/antrax/cli.py", line 659, in main
    """)
  File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/sigtools/modifiers.py", line 158, in __call__
    return self.func(*args, **kwargs)
  File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/clize/runner.py", line 363, in run
    ret = cli(*args)
  File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/clize/runner.py", line 220, in __call__
    return func(*posargs, **kwargs)
  File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/clize/runner.py", line 262, in _cli
    return func('{0} {1}'.format(name, command), *args)
  File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/clize/runner.py", line 220, in __call__
    return func(*posargs, **kwargs)
  File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/antrax/cli.py", line 447, in train
    c.train(examplesdir, ne=ne, aug_options=aug_options)
  File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/antrax/classifier.py", line 513, in train
    cw = class_weight.compute_class_weight('balanced', np.unique(FL.classes), FL.classes)
TypeError: compute_class_weight() takes 1 positional argument but 3 were given

It seems to be an error regarding the Matlab python engine version however I am using Matlab R2019a and pip list shows I have matlabengineforpython R2018a installed.
Any help fixing this would be appreciated.

@asafgal
Copy link
Contributor

asafgal commented Jan 12, 2022

Hey Sean,
This is a python error, not related to the matlab engine.
Can you try this fix:

In the file anTraX/antrax/classifier.py, change line 513 to:

cw = class_weight.compute_class_weight(class_weight='balanced', classes =np.unique(FL.classes), y=FL.classes)

Then update the python code with pip install -e .
I am unable to test this myself currently, so let me know what happens!

@Sean-Nolan6
Copy link
Author

Hi your first solution helped the first issue, but I'm currently trialing your other datasets to get a sense of how long my tests were. However when I try and run train on the V25 sample, it keeps coming up with the same error:

Epoch 1/3
124/1000 [==>...........................] - ETA: 5:54 - loss: 3.5632 - acc: 0.3478Traceback (most recent call last):
File "/home/sean/anaconda3/envs/test/bin/antrax", line 33, in
sys.exit(load_entry_point('antrax', 'console_scripts', 'antrax')())
File "/home/sean/Documents/AntTrax/anTraX/antrax/cli.py", line 659, in main
""")
File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/sigtools/modifiers.py", line 158, in call
return self.func(*args, **kwargs)
File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/clize/runner.py", line 363, in run
ret = cli(*args)
File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/clize/runner.py", line 220, in call
return func(*posargs, **kwargs)
File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/clize/runner.py", line 262, in _cli
return func('{0} {1}'.format(name, command), *args)
File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/clize/runner.py", line 220, in call
return func(*posargs, **kwargs)
File "/home/sean/Documents/AntTrax/anTraX/antrax/cli.py", line 447, in train
c.train(examplesdir, ne=ne, aug_options=aug_options)
File "/home/sean/Documents/AntTrax/anTraX/antrax/classifier.py", line 533, in train
verbose=verbose)
File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training.py", line 1296, in fit_generator
steps_name='steps_per_epoch')
File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training_generator.py", line 221, in model_iteration
batch_data = _get_next_batch(generator)
File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training_generator.py", line 363, in _get_next_batch
generator_output = next(generator)
File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/tensorflow_core/python/keras/utils/data_utils.py", line 789, in get
six.reraise(*sys.exc_info())
File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/six.py", line 719, in reraise
raise value
File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/tensorflow_core/python/keras/utils/data_utils.py", line 783, in get
inputs = self.queue.get(block=True).get()
File "/home/sean/anaconda3/envs/test/lib/python3.7/multiprocessing/pool.py", line 657, in get
raise self._value
File "/home/sean/anaconda3/envs/test/lib/python3.7/multiprocessing/pool.py", line 121, in worker
result = (True, func(*args, **kwds))
File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/tensorflow_core/python/keras/utils/data_utils.py", line 571, in get_index
return _SHARED_SEQUENCES[uid][i]
File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/keras_preprocessing/image/iterator.py", line 65, in getitem
return self._get_batches_of_transformed_samples(index_array)
File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/keras_preprocessing/image/iterator.py", line 230, in _get_batches_of_transformed_samples
interpolation=self.interpolation)
File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/keras_preprocessing/image/utils.py", line 114, in load_img
img = pil_image.open(io.BytesIO(f.read()))
File "/home/sean/anaconda3/envs/test/lib/python3.7/site-packages/PIL/Image.py", line 3009, in open
"cannot identify image file %r" % (filename if filename else fp)
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7f37b8629470>

@asafgal
Copy link
Contributor

asafgal commented Feb 18, 2022

Both errors are due to compatibility issue with 3rd party packages.
To fix your last error, reinstall the pillow package:

pip uninstall pillow
pip install pillow==8.4.0

Thanks for bringing this to my attention, I will update the requirement file accordingly.

@Sean-Nolan6
Copy link
Author

Uninstalling and installing pillow doesn't seem to have fixed the issue, any other ideas to what it might be?

@asafgal
Copy link
Contributor

asafgal commented Feb 21, 2022

Can you verify the pillow version?
In a python console:

import PIL
print(PIL.__version__)

@Sean-Nolan6
Copy link
Author

This is the error I get:
(test) sean@seans-ants:~$ import PIL
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 28, in
from CommandNotFound import CommandNotFound
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in
from CommandNotFound.db.db import SqliteDatabase
File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in
import apt_pkg
ImportError: /usr/local/MATLAB/MATLAB_Runtime/v96/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /lib/x86_64-linux-gnu/libapt-pkg.so.6.0)

@asafgal
Copy link
Contributor

asafgal commented Feb 23, 2022 via email

mpice-mn added a commit to mpice-mn/anTraX that referenced this issue Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants