pooya-mohammadi / yolov5-gradcam

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

self.model(img, augment=False) does not work #30

Open arpan-kusari opened 1 year ago

arpan-kusari commented 1 year ago

Hi, Thanks for the repo. Whenever I am running it, I am getting an error on the self.model command. It seems it does not output pred and logits but a single tensor when given a tensor. Not sure how this line could be updated.

Traceback (most recent call last): File "C:\Users\kusari\Documents\Camera_error_sources\yolov5-gradcam\main.py", line 124, in main(args.img_path) File "C:\Users\kusari\Documents\Camera_error_sources\yolov5-gradcam\main.py", line 67, in main saliency_method = YOLOV5GradCAM(model=model, layer_name=args.target_layer, img_size=input_size) File "C:\Users\kusari\Documents\Camera_error_sources\yolov5-gradcam\models\gradcam.py", line 44, in init self.model(torch.zeros(1, 3, img_size, device=device)) File "C:\Users\kusari\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl return forward_call(input, **kwargs) File "C:\Users\kusari\Documents\Camera_error_sources\yolov5-gradcam\models\yolo_v5_objectdetector.py", line 167, in forward prediction, logits, = self.model(img, augment=False) ValueError: not enough values to unpack (expected 3, got 2)

Junxiang-Zeng8443 commented 1 year ago

May I ask if your problem has been resolved? I have also encountered the same problem

Traceback (most recent call last): File "D:\jupyter\pythonProject\yolov5-gradcam-master\main.py", line 124, in main(args.img_path) File "D:\jupyter\pythonProject\yolov5-gradcam-master\main.py", line 67, in main saliency_method = YOLOV5GradCAM(model=model, layer_name=args.target_layer, img_size=input_size) File "D:\jupyter\pythonProject\yolov5-gradcam-master\models\gradcam.py", line 44, in init self.model(torch.zeros(1, 3, img_size, device=device)) File "C:\Users\y\AppData\Roaming\Python\Python39\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(args, **kwargs) File "D:\jupyter\pythonProject\yolov5-gradcam-master\models\yolo_v5_objectdetector.py", line 167, in forward prediction, logits, = self.model(img, augment=False) ValueError: not enough values to unpack (expected 3, got 2)

Junxiang-Zeng8443 commented 1 year ago

Waiting for your reply