pooya-mohammadi / yolov5-gradcam

Visualizing Yolov5's layers using GradCam

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

mjuhbgtfc opened this issue · comments

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'>

do you fix it?

do you fix it?

not yet

did you fix it?

same problem

anyone fixed the issue?

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

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

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

Which version of yolov5?

commented

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

v 7.0

commented

v 7.0

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

same problem here

did anyone fix this?

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