ifzhang/ByteTrack

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

Closed this issue · 8 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```

A temporary way to bypass: np.float = float

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

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

@ahmadshah2103 thank youu!! It's working!

->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 Thank you for providing the details.

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

A temporary way to bypass: np.float = float

@rahul12st Try this one.