Open fereshteramez opened 2 years ago
For now, we support a script to calculate the confusion matrix offline. The online confusion matrix calculation is not supported.
I tried the "confusion_matrix.py" to calculate the confusion matrix, however it gives me error concerning the results input which should be in pkl format. Therefore, I tried "test.py" to generate the results.pkl on my own test set as below:
!python tools/test.py /content/mmdetection/configs/detectors/detectors_cascade_rcnn_r50_1x_coco.py /content/mmdetection/tutorial_exps3/latest.pth --out results.pkl
content/mmdetection/mmdet/utils/setup_env.py:39: UserWarning: Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed.
f'Setting OMP_NUM_THREADS environment variable for each process '
/content/mmdetection/mmdet/utils/setup_env.py:49: UserWarning: Setting MKL_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed.
f'Setting MKL_NUM_THREADS environment variable for each process '
loading annotations into memory...
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/mmcv/utils/registry.py", line 66, in build_from_cfg
return obj_cls(**args)
File "/content/mmdetection/mmdet/datasets/custom.py", line 95, in __init__
self.data_infos = self.load_annotations(local_path)
File "/content/mmdetection/mmdet/datasets/coco.py", line 72, in load_annotations
self.coco = COCO(ann_file)
File "/content/mmdetection/mmdet/datasets/api_wrappers/coco_api.py", line 23, in __init__
super().__init__(annotation_file=annotation_file)
File "/usr/local/lib/python3.7/dist-packages/pycocotools/coco.py", line 81, in __init__
with open(annotation_file, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'data/coco/annotations/instances_val2017.json'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tools/test.py", line 275, in <module>
main()
File "tools/test.py", line 217, in main
dataset = build_dataset(cfg.data.test)
File "/content/mmdetection/mmdet/datasets/builder.py", line 82, in build_dataset
dataset = build_from_cfg(cfg, DATASETS, default_args)
File "/usr/local/lib/python3.7/dist-packages/mmcv/utils/registry.py", line 69, in build_from_cfg
raise type(e)(f'{obj_cls.__name__}: {e}')
FileNotFoundError: CocoDataset: [Errno 2] No such file or directory: 'data/coco/annotations/instances_val2017.json'
Since the code above did not work, I was wondering how I can get my results in the code below in pkl format (I trained the algorithm on my own dataset and I apply it on the test set here):
from mmdet.apis import init_detector, inference_detector, show_result_pyplot
from google.colab.patches import cv2_imshow
from skimage.io import imread_collection
model.cfg = cfg
# path to the images
col_dir = '/content/sample_data/data/test/*.jpg'
#creating a collection with the available images
col = imread_collection(col_dir)
for i in range(len(col)):
# image=col[i]
name=col.files[i]
# name=name.split("test/") # reading the name of the image
# output_name=name[1]
image=mmcv.imread(name)
cv2_imshow(image)
result = inference_detector(model, image)
show_result_pyplot(model, image, result)
It seems that you have not set the correct path of the dataset. You can modify this line to the correct path: https://github.com/open-mmlab/mmdetection/blob/e71b499608e9c3ccd4211e7c815fa20eeedf18a2/configs/_base_/datasets/coco_detection.py#L41
Hi. I was wondering how to get the confusion matrix during the training and saving the results (without using test.py). Here is my code to train DetectoRS on a custom dataset: