1. Image demonstration
1.1 Below is a demo script to test a single image.
python demo/image_demo.py ${IMAGE_FILE} ${CONFIG_FILE} ${CHECKPOINT_FILE} [--device ${GPU_ID}] [--score-thr ${SCORE_THR}]
IMAGE_FILE : The path to the test image is required.
CONFIG_FILE : The path to the corresponding configuration file.
CHECKPOINT_FILE : Path to the weights file used for testing.
--device : The ID number of the GPU used.
For example:
python demo/image_demo.py demo/demo.jpg configs/faster_rcnn_r50_fpn_1x_coco.py checkpoints/faster_rcnn_r50_fpn_1x_20181010-3d1b3351.pth --device cpu
Run the image_demo.py code under the demo path, the image path is demo/demo.jpg, the configuration file path used is configs/faster_rcnn_r50_fpn_1x_coco.py, the weight file path used for testing is checkpoints/faster_rcnn_r50_fpn_1x_20181010-3d1b3351.pth, and the device uses cpu - -device cpu.
1.2 Webcam demo, the following is a webcam demo.
python demo/webcam_demo.py ${CONFIG_FILE} ${CHECKPOINT_FILE} [--device ${GPU_ID}] [--camera-id ${CAMERA-ID}] [--score-thr ${SCORE_THR}]
There is no need to test the image path because the webcam is used directly for live presentations.
CONFIG_FILE : The path to the corresponding configuration file.
CHECKPOINT_FILE : Path to the weights file used for testing.
--device : The ID number of the GPU used.
For example:
python demo/webcam_demo.py configs/faster_rcnn_r50_fpn_1x_coco.py checkpoints/faster_rcnn_r50_fpn_1x_20181010-3d1b3351.pth
Run the webcam_demo.py code under the demo path, the configuration file path used is configs/faster_rcnn_r50_fpn_1x_coco.py, and the weight file path used for testing is checkpoints/faster_rcnn_r50_fpn_1x_20181010-3d1b3351.pth.
2. Analysis logs
2.1 The loss/mAP curve can be drawn given the training log file
First run pip-install-seaborn to install dependencies.
pip install seaborn
python tools/analyze_logs.py plot_curve [--keys ${KEYS}] [--title ${TITLE}] [--legend ${LEGEND}] [--backend ${BACKEND}] [--style ${STYLE}] [--out ${OUT_FILE}]
Then call the analyze_logs.py program under the tools folder to draw the curve. For specific parameters, refer to 2.2.
2.2 Parameter details
plot_curve : Analyzer for plotting curves.
json_logs : The training log path in json format.
--keys : The amount to draw, which can be loss_cls, loss_bbox, bbox_mAP.
--title : Graphic title.
--legend : Legend for each plot.
--backend : Drawing backend.
--style : Drawing style.
cal_train_time : Parser used to calculate the average time per training iteration.
--include-outliers : Include the first value of each generation when calculating the average time.
2.3 Example display
2.3.1 Draw some running classification losses and save them in png format. The formats that can be saved are .png, .jpg, .pdf, etc.
python tools/analyze_logs.py plot_curve log.json --keys loss_cls --legend loss_cls --out loss_cls.png
Run the analyze_logs.py file, call the analyzer plot_curve, the training log path in json format is log.json, the amount to be drawn is --keys loss_cls classification loss, the drawn legend is --legend loss_cls classification loss legend, and the output loss map is saved for --out loss_cls.png.
2.3.2 Plot the classification and regression losses for a few runs and save the plot as a pdf.
python tools/analyze_logs.py plot_curve log.json --keys loss_cls loss_bbox --out losses.pdf
Run the analyze_logs.py file, call the analyzer plot_curve, the training log path in json format is log.json, the amount to be drawn is --keys loss_cls loss_bbox classification loss and regression loss, and the output loss graph is saved as --out lossse.pdf.
2.3.3 Comparing the bbox mAP of two runs in the same figure.
python tools/analyze_logs.py plot_curve log1.json log2.json --keys bbox_mAP --legend run1 run2
Run the analyze_logs.py file, call the analyzer plot_curve, the training log path in json format is two log1.json and log2.json that need to be compared, the amount to be drawn is --keys bbox_mAP, and the drawn legend is run1 and run2, respectively bbox_mAP representing the two curves.
2.3.4 Calculate the average training speed.
python tools/analyze_logs.py cal_train_time log.json [--include-outliers]
3. Obtain FLOPS and Params (calculation amount and parameter amount)
get_flops.py script to calculate FLOPs and parameters for a given model.
python tools/get_flops.py ${CONFIG_FILE} [--shape ${INPUT_SHAPE}]
Detailed explanation of the parameters:
CONFIG_FILE : path to the training config file.
--shape : Input image size.