ByteTrack icon indicating copy to clipboard operation
ByteTrack copied to clipboard

AttributeError: module 'numpy' has no attribute 'float'

Open ahmadshah2103 opened this issue 2 years ago • 3 comments

I got the following error when using the BYTEtracker.update() method. Here are the error details:

Cell In[12], line 16
      8 results = model(frame)[0]
     10 detections = Detections(
     11     xyxy=results.boxes.xyxy.cpu().numpy(),
     12     confidence=results.boxes.conf.cpu().numpy(),
     13     class_id=results.boxes.cls.cpu().numpy().astype(int)
     14 )
---> 16 tracks = byte_tracker.update(
     17     output_results=detections2boxes(detections=detections),
     18     img_info=frame.shape,
     19     img_size=frame.shape
     20 )
     21 tracker_id = match_detections_with_tracks(detections=detections, tracks=tracks)
     22 detections.tracker_id = np.array(tracker_id)

File ~\anaconda3\Lib\site-packages\yolox\tracker\byte_tracker.py:207, in BYTETracker.update(self, output_results, img_info, img_size)
    205 # Predict the current location with KF
    206 STrack.multi_predict(strack_pool)
--> 207 dists = matching.iou_distance(strack_pool, detections)
    208 if not self.args.mot20:
    209     dists = matching.fuse_score(dists, detections)

File ~\anaconda3\Lib\site-packages\yolox\tracker\matching.py:88, in iou_distance(atracks, btracks)
     86     atlbrs = [track.tlbr for track in atracks]
     87     btlbrs = [track.tlbr for track in btracks]
---> 88 _ious = ious(atlbrs, btlbrs)
     89 cost_matrix = 1 - _ious
     91 return cost_matrix

File ~\anaconda3\Lib\site-packages\yolox\tracker\matching.py:61, in ious(atlbrs, btlbrs)
     53 def ious(atlbrs, btlbrs):
     54     """
     55     Compute cost based on IoU
     56     :type atlbrs: list[tlbr] | np.ndarray
   (...)
     59     :rtype ious np.ndarray
     60     """
---> 61     ious = np.zeros((len(atlbrs), len(btlbrs)), dtype=np.float)
     62     if ious.size == 0:
     63         return ious

File ~\anaconda3\Lib\site-packages\numpy\__init__.py:305, in __getattr__(attr)
    300     warnings.warn(
    301         f"In the future `np.{attr}` will be defined as the "
    302         "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
    304 if attr in __former_attrs__:
--> 305     raise AttributeError(__former_attrs__[attr])
    307 # Importing Tester requires importing all of UnitTest which is not a
    308 # cheap import Since it is mainly used in test suits, we lazy import it
    309 # here to save on the order of 10 ms of import time for most users
    310 #
    311 # The previous way Tester was imported also had a side effect of adding
    312 # the full `numpy.testing` namespace
    313 if attr == 'testing':

AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations```

ahmadshah2103 avatar Jan 14 '24 04:01 ahmadshah2103

A temporary way to bypass: np.float = float

qrsforever avatar Jan 29 '24 02:01 qrsforever

@ahmadshah2103 can you fix the problem? helpe me plase! I have the same problem :(

kevinpal10 avatar Feb 21 '24 04:02 kevinpal10

@kevinpal10 you can change it in the source code, it worked for me. OR you can try @qrsforever solution.

ahmadshah2103 avatar Feb 21 '24 06:02 ahmadshah2103

@ahmadshah2103 thank youu!! It's working!

kevinpal10 avatar Feb 22 '24 01:02 kevinpal10

->ByteTrack -> yolox -> tracker -> byte_tracker.py and matching.py

In these two .py files you should change "np.float" to "float" OR in the requirements.txt file numpy version should be 1.22.4 or lower version!

thecetin avatar Feb 23 '24 11:02 thecetin

@thecetin Thank you for providing the details.

ahmadshah2103 avatar Feb 23 '24 12:02 ahmadshah2103

didnt work for me showing same error even after changing np.float in byte_tracker.py and matching.py

rahul12st avatar Jun 05 '24 06:06 rahul12st

A temporary way to bypass: np.float = float

@rahul12st Try this one.

ahmadshah2103 avatar Jun 13 '24 19:06 ahmadshah2103