boxmot icon indicating copy to clipboard operation
boxmot copied to clipboard

Error when loading Yolov7 weights

Open bit-scientist opened this issue 2 years ago • 6 comments

Search before asking

  • [X] I have searched the Yolov5_StrongSORT_OSNet issues and found no similar bug report.

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.

bit-scientist avatar Aug 03 '22 02:08 bit-scientist

This repo can only load Yolov5 models sorry

mikel-brostrom avatar Aug 03 '22 05:08 mikel-brostrom

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

bit-scientist avatar Aug 03 '22 23:08 bit-scientist

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 avatar Aug 04 '22 06:08 mikel-brostrom

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

mikel-brostrom avatar Aug 04 '22 15:08 mikel-brostrom

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.

bit-scientist avatar Aug 05 '22 00:08 bit-scientist

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

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

mikel-brostrom avatar Aug 10 '22 09:08 mikel-brostrom

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?

albertomenen avatar Feb 05 '24 09:02 albertomenen

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

mikel-brostrom avatar Feb 05 '24 09:02 mikel-brostrom

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

mikel-brostrom avatar Feb 05 '24 09:02 mikel-brostrom