Train
Train your own data set
python tools/train.py configs/xxxx.py
Copy the code
The. PTH file generated after training is the training model
Test
Test your own data set
--out Takes the path of the out file and generates a. PKL file. The PKL file stores four items of the check box in an array. Proposal_fast, proposal, Bbox, SEGM, Keypoints *(debug: mAP evaluation error), the evaluated data is displayed at the end of the test action in a small black window --show visualization, including categories and detection boxesCopy the code
Py work_dirs/ XXXX /epoch_xx. PTH --out xxx.pkl --show-dir XXX Path Save the visualization result in the specified python path tools/test.py configs/xxxx.py work_dirs/xxxx/epoch_xx.pth --show-dir ./resultCopy the code
About displaying. PKL file contents: blog.csdn.net/weixin_3945…
Many training classes
Usually, we train a class of targets on the MMDetection platform. During the training, we can check the accuracy of the target under threshold values such as 0.5 and 0.75 with an overall mAP after each epoch is run. But when you’re running multiple targets, what about the accuracy of a single target when multiple targets are trained together? The default setting of MMDetection is to print the overall accuracy when multi-class targets are trained together. If you want to check the accuracy of a single class during training and testing, you can perform the following operations (the premise of the following operations is that you have been trained and the multi-class configuration files related to multi-class training have been modified) : In mmdetection/mmdet/datasets/coco. Py found in the following code:
def evaluate(self,
results,
metric='bbox',
logger=None,
jsonfile_prefix=None,
classwise=False,
proposal_nums=(100.300.1000),
iou_thrs=None,
metric_items=None):
Copy the code
Change classwise=False to classwise=True to add a single AP table
Qualified threshold evaluation
However, the single accuracy rate in the figure above is not a good evaluation index. It is an average value taken by AP at various stages, and the comprehensive evaluation result taken within the range of 0.5 to 0.95. We need to further limit the accuracy rate under a certain threshold, for example, the accuracy rate when the threshold is set at 0.5. Change iou_thrs=None to iou_thrs=[0.5]
Test individual images
#coding=utf-8
from mmdet.apis import init_detector
from mmdet.apis importInference_detector # Due to mmDetection version update, show_result is used as model.show_result #from mmdet.apis importShow_result # Model configuration file config_file ='.. /.. /configs/faster_rcnn_r101_fpn_1x.py'# pretrain model file checkpoint_file ='.. /.. /models/faster_rcnn_r101_fpn_1x_20181129-d1468807.pth'Model = init_detector(config_file, checkpoint_file, device='cuda:0') # Test the single image and show it. Img ='test1.jpg'
result = inference_detector(model, img)
model.show_result(img, result, model.CLASSES)
Copy the code