open-mmlab / mmyolo

OpenMMLab YOLO series toolbox and benchmark. Implemented RTMDet, RTMDet-Rotated,YOLOv5, YOLOv6, YOLOv7, YOLOv8,YOLOX, PPYOLOE, etc.
https://mmyolo.readthedocs.io/zh_CN/dev/
GNU General Public License v3.0
3.02k stars 544 forks source link

使用GradCAM报错 #540

Closed yaofanji closed 1 year ago

yaofanji commented 1 year ago

root@autodl-container-2db1118bae-37fa7cbb:~/mmyolo# python demo/boxam_vis_demo.py mmyolo/configs/yolov8/yolov8_m_syncbn_fast_8xb16-500e_coco.py ./work_dirs/yolov8_m_syncbn_fast_8xb16-500e_coco/epoch_300.pth Traceback (most recent call last): File "demo/boxam_vis_demo.py", line 22, in from mmyolo.utils.boxam_utils import (BoxAMDetectorVisualizer, File "/root/mmyolo/mmyolo/utils/boxam_utils.py", line 342, in class DetAblationLayer(AblationLayer): NameError: name 'AblationLayer' is not defined

mm-assistant[bot] commented 1 year ago

We recommend using English or English & Chinese for issues so that we could have broader discussion.

hhaAndroid commented 1 year ago

@yaofanji pip install grad-cam

yaofanji commented 1 year ago

Loads checkpoint by local backend from path: ./work_dirs/yolov8_m_syncbn_fast_8xb16-500e_coco/epoch_300.pth [ ] 0/1, elapsed: 0s, ETA:/root/miniconda3/lib/python3.8/site-packages/torch/functional.py:568: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:2228.) return _VF.meshgrid(tensors, kwargs) # type: ignore[attr-defined] Traceback (most recent call last): File "demo/boxam_vis_demo.py", line 276, in main() File "demo/boxam_vis_demo.py", line 239, in main grayscale_boxam = boxam_detector_visualizer(image, targets=targets) File "/root/mmyolo/mmyolo/utils/boxam_utils.py", line 278, in call return self.cam(img, targets, aug_smooth, eigen_smooth)[0, :] File "/root/miniconda3/lib/python3.8/site-packages/pytorch_grad_cam/base_cam.py", line 188, in call return self.forward(input_tensor, File "/root/miniconda3/lib/python3.8/site-packages/pytorch_grad_cam/base_cam.py", line 74, in forward outputs = self.activations_and_grads(input_tensor) File "/root/miniconda3/lib/python3.8/site-packages/pytorch_grad_cam/activations_and_gradients.py", line 42, in call return self.model(x) File "/root/mmyolo/mmyolo/utils/boxam_utils.py", line 212, in call loss = self.detector._run_forward(data, mode='loss') File "/root/miniconda3/lib/python3.8/site-packages/mmengine/model/base_model/base_model.py", line 320, in _run_forward results = self(data, mode=mode) File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, *kwargs) File "/root/miniconda3/lib/python3.8/site-packages/mmdet/models/detectors/base.py", line 92, in forward return self.loss(inputs, data_samples) File "/root/miniconda3/lib/python3.8/site-packages/mmdet/models/detectors/single_stage.py", line 78, in loss losses = self.bbox_head.loss(x, batch_data_samples) File "/root/mmyolo/mmyolo/models/dense_heads/yolov5_head.py", line 459, in loss losses = super().loss(x, batch_data_samples) File "/root/miniconda3/lib/python3.8/site-packages/mmdet/models/dense_heads/base_dense_head.py", line 123, in loss losses = self.loss_by_feat(loss_inputs) File "/root/mmyolo/mmyolo/models/dense_heads/yolov8_head.py", line 307, in loss_by_feat gt_info = self.gt_instances_preprocess(batch_gt_instances, num_imgs) File "/root/mmyolo/mmyolo/models/dense_heads/yolov8_head.py", line 417, in gt_instances_preprocess bboxes = gt_instance.bboxes AttributeError: 'dict' object has no attribute 'bboxes

hhaAndroid commented 1 year ago

@yaofanji Thanks for your feedback, let's check it out.

hhaAndroid commented 1 year ago

Resolved https://github.com/open-mmlab/mmyolo/pull/601