pooya-mohammadi / yolov5-gradcam

Visualizing Yolov5's layers using GradCam
MIT License
281 stars 47 forks source link

Can't get attribute 'DetectionModel' on <module 'models.yolo' from....> #23

Open Kris-Leo opened 2 years ago

Kris-Leo commented 2 years ago

Here's my code...↓


! pip install -r requirements.txt

import os
os.chdir("./yolov5-gradcam-master/")

!python main.py --model-path runs/train/hat_person4/weights/best.pt --img-path datasets/hat_person/yolo_dataset/images/train/000490.jpg --output-dir outputs --names hat,person   

And then...Something wrong..

[INFO] Loading the model Traceback (most recent call last): File "main.py", line 124, in main(args.img_path) File "main.py", line 64, in main names=None if args.names is None else args.names.strip().split(",")) File "f:\works\VSCODE\yolov5\yolov5-gradcam-master\models\yolo_v5_object_detector.py", line 32, in __init__ self.model = attempt_load(model_weight, device=device) File "f:\works\VSCODE\yolov5\yolov5-gradcam-master\models\experimental.py", line 80, in attempt_load ckpt = torch.load(attempt_download(w), map_location=device) File "d:\Anaconda3\envs\yolo\lib\site-packages\torch\serialization.py", line 607, in load return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args) File "d:\Anaconda3\envs\yolo\lib\site-packages\torch\serialization.py", line 882, in _load result = unpickler.load() File "d:\Anaconda3\envs\yolo\lib\site-packages\torch\serialization.py", line 875, in find_class return super().find_class(mod_name, name) AttributeError: Can't get attribute 'DetectionModel' on <module 'models.yolo' from 'f:\works\VSCODE\yolov5\yolov5-gradcam-master\models\yolo.py'>

present-gift commented 1 year ago

do you fix it?

Kris-Leo commented 1 year ago

do you fix it?

not yet

saisriteja commented 1 year ago

did you fix it?

mcasini commented 1 year ago

same problem

mohaliyet commented 1 year ago

anyone fixed the issue?

LinRds commented 1 year ago

I fix it by update the models/yolo.py (yolov5 reposipotry)

mohaliyet commented 1 year ago

@LinRds could you please tell me how? Or, direct me to the updated fork?

xiaoling-1 commented 1 year ago

I fix it by update the models/yolo.py (yolov5 reposipotry)

Which version of yolov5?

LinRds commented 1 year ago

@LinRds could you please tell me how? Or, direct me to the updated fork?

v 7.0

LinRds commented 1 year ago

v 7.0

kiran-coditation commented 1 year ago

Hey does anyone know the solution of this issue ? @LinRds @saisriteja @mohaliyet @xiaoling-1

iurimolina commented 1 year ago

same problem here

iurimolina commented 1 year ago

did anyone fix this?

rokopi-byte commented 1 year ago

The problem is retated to the yolov5 version used to train the model vs the version included in this repo. A quick fix is to add in yolo.py at line 251 the following:

DetectionModel = Model