mikel-brostrom / boxmot

BoxMOT: pluggable SOTA tracking modules for segmentation, object detection and pose estimation models
GNU Affero General Public License v3.0
6.7k stars 1.71k forks source link

Error when loading Yolov7 weights #478

Closed bit-scientist closed 2 years ago

bit-scientist commented 2 years ago

Search before asking

Question

Well, I have a custom yolov7.pt model trained with a recent github repo. Assuming a custom yolov7_best.pt model to be similar to yolov5, I tried a command python track.py --source demo.mp4 --yolo-weights weights/yolov7_best.pt. But, it is giving an error: AttributeError: Can't get attribute 'MP' on <module 'models.common' from 'D:\\projects\\Yolov5_StrongSORT_OSNet\\yolov5\\models\\common.py'>

A couple of days ago, I successfully tested track.py several times with custom yolov5 models with a command python track.py --source demo.mp4 --yolo-weights weights/yolov5n.pt and got results in run folder.

I can't find what MP in AttributeError is.

mikel-brostrom commented 2 years ago

This repo can only load Yolov5 models sorry

bit-scientist commented 2 years ago

I see, do you have any plan to add yolov7 in the near future?

mikel-brostrom commented 2 years ago

Yolov7 do not have multibackend support. It only works with PT weights. The goal of this repo is to be as versatile as possible and support as many deployment scenarios as possible. Substituting Yolov5 for Yolov7 does not make this repo go in this direction.

mikel-brostrom commented 2 years ago

I see, do you have any plan to add yolov7 in the near future?

You can try it out here @bit-scientist

https://github.com/mikel-brostrom/Yolov5_StrongSORT_OSNet/tree/yolov7

Automatic weight download is not fully supported, you will have to download them yourself

bit-scientist commented 2 years ago

thanks, @mikel-brostrom . I cloned yolov7 into the repo as you guided. When I ran python track.py --source video_short.mp4 --yolo-weights weights/yolov7_best.pt, it threw TypeError: StrongSORT.__init__() got multiple values for argument 'max_dist'. After inspecting, I came to know that max_dist argument was being overwritten, thus I commented out that line in track.py. This time the above command also requires deepsort weights as you mentioned, right? Because I got No URL associated to the chosen DeepSort weights. Choose between: Therefore, I also downloaded osnet_x0_25_msmt17_256x128_amsgrad_ep180_stp80_lr0.003_b128_fb10_softmax_labelsmooth_flip.pth and put it inside weights folder. If things are on the right track up to this point let me know.

I set the DeepSort weight file as default for --strong-sort-weights and executed python track.py --source video_short.mp4 --yolo-weights weights/yolov7_best.pt again. But it is outputting:

File "S:\Yolov5_StrongSORT_OSNet\track.py", line 139, in run
    strongsort_list[i].model.warmup()
AttributeError: 'StrongSORT' object has no attribute 'model'

I wasn't able to trace the error so far.

mikel-brostrom commented 2 years ago

Have it working now @bit-scientist! CI is passing

https://github.com/mikel-brostrom/Yolov7_StrongSORT_OSNet

albertomenen commented 9 months ago

Hello there!

So we are experiencing some problems in our system when we add yolo7, i see that there is the same problem with weights. The error message shows this:


Traceback (most recent call last):
  File "/home/gustavotremont/Alberto/yolov7/utils/google_utils.py", line 26, in attempt_download
    assets = [x['name'] for x in response['assets']]  # release assets
KeyError: 'assets'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/gustavotremont/Alberto/yolov7/detect.py", line 294, in <module>
    detect()
  File "/home/gustavotremont/Alberto/yolov7/detect.py", line 54, in detect
    model = attempt_load(weights, map_location=device)  # load FP32 model
  File "/home/gustavotremont/Alberto/yolov7/models/experimental.py", line 251, in attempt_load
    attempt_download(w)
  File "/home/gustavotremont/Alberto/yolov7/utils/google_utils.py", line 31, in attempt_download
    tag = subprocess.check_output('git tag', shell=True).decode().split()[-1]
IndexError: list index out of range

Any idea what is the cause?

mikel-brostrom commented 9 months ago

https://github.com/WongKinYiu/yolov7/issues/1205 https://github.com/WongKinYiu/yolov7/pull/1262

mikel-brostrom commented 9 months ago

Feel free to create a PR for Yolov7 @albertomenen :smile: