ahmetozlu / tensorflow_object_counting_api

🚀 The TensorFlow Object Counting API is an open source framework built on top of TensorFlow and Keras that makes it easy to develop object counting systems!
https://www.youtube.com/watch?v=yT_1eKJTdfk
MIT License
1.32k stars 545 forks source link

ModuleNotFoundError: No module named 'sklearn.utils.linear_assignment_' #78

Closed frainmaster closed 4 years ago

frainmaster commented 4 years ago

Hello, I tried to run the object_tracking.py file but it shows the error:

ModuleNotFoundError: No module named 'sklearn.utils.linear_assignment_'

It is said that the problem is from line 10 of backbone.py which is

from sklearn.utils.linear_assignment_ import linear_assignment

Untitled

Please assist me with this. Thank you.

heyuanfly commented 4 years ago

The linear_assignment function is deprecated in 0.21 and will be removed from 0.23,but sklearn.utils.linear_assignment_ can be replaced by scipy.optimize.linear_sum_assignment You can use from scipy.optimize import linear_sum_assignment as linear_assignment ,than you can run the file and don't need to change the code or you can try to use sklearn<=0.19. You may learn more details here: https://github.com/scikit-learn/scikit-learn/pull/13465 https://github.com/scikit-learn/scikit-learn/pull/13480 https://github.com/scikit-learn/scikit-learn/issues/13464

frainmaster commented 4 years ago

I am sorry for the late reply since I just had a free time to continue on this work.

I implemented the fix in backbone.py and I got another error in detection_layer.py. It is regarding Tensorflow version (mine is 2.2.0) which, as suggested by this page, can be fixed by changing:

import tensorflow as tf

to

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

I tell this so that someone else whom had this error can find this solution. ANYWAY, I have another error in backbone.py. This time comes from line 40 of the original file which shows this error:

TypeError: tuple indices must be integers or slices, not tuple

As shown in the command prompt... Untitled

Please assist. Thank you.

frainmaster commented 4 years ago

I have solved this issue. Basically you cannot run the file object_tracking.py. Use other files like pedestrian_counting.py, vehicle_counting.py, etc.