We provide lots of useful tools under the tools/
directory. In addition, you can also quickly run other open source libraries of OpenMMLab through MIM.
Take MMDetection as an example. If you want to use print_config.py, you can directly use the following commands without copying the source code to the MMYOLO library.
mim run mmdet print_config [CONFIG]
Note: The MMDetection library must be installed through the MIM before the above command can succeed.
tools/analysis_tools/browse_coco_json.py
is a script that can visualization to display the COCO label in the picture.
python tools/analysis_tools/browse_coco_json.py ${DATA_ROOT} \
[--ann_file ${ANN_FILE}] \
[--img_dir ${IMG_DIR}] \
[--wait-time ${WAIT_TIME}] \
[--disp-all] [--category-names CATEGORY_NAMES [CATEGORY_NAMES ...]] \
[--shuffle]
E.g:
- Visualize all categories of
COCO
and display all types of annotations such asbbox
andmask
:
python tools/analysis_tools/browse_coco_json.py './data/coco/' \
--ann_file 'annotations/instances_train2017.json' \
--img_dir 'train2017' \
--disp-all
- Visualize all categories of
COCO
, and display only thebbox
type labels, and shuffle the image to show:
python tools/analysis_tools/browse_coco_json.py './data/coco/' \
--ann_file 'annotations/instances_train2017.json' \
--img_dir 'train2017' \
--shuffle
- Only visualize the
bicycle
andperson
categories ofCOCO
and only thebbox
type labels are displayed:
python tools/analysis_tools/browse_coco_json.py './data/coco/' \
--ann_file 'annotations/instances_train2017.json' \
--img_dir 'train2017' \
--category-names 'bicycle' 'person'
- Visualize all categories of
COCO
, and display all types of label such asbbox
,mask
, and shuffle the image to show:
python tools/analysis_tools/browse_coco_json.py './data/coco/' \
--ann_file 'annotations/instances_train2017.json' \
--img_dir 'train2017' \
--disp-all \
--shuffle
tools/analysis_tools/browse_dataset.py
helps the user to browse a detection dataset (both images and bounding box annotations) visually, or save the image to a designated directory.
python tools/analysis_tools/browse_dataset.py ${CONFIG} \
[-h] \
[--output-dir ${OUTPUT_DIR}] \
[--not-show] \
[--show-interval ${SHOW_INTERVAL}]
E,g:
- Use
config
fileconfigs/yolov5/yolov5_s-v61_syncbn_8xb16-300e_coco.py
to visualize the picture. The picture will pop up directly and be saved to the directorywork dir/browse_ dataset
at the same time:
python tools/analysis_tools/browse_dataset.py 'configs/yolov5/yolov5_s-v61_syncbn_8xb16-300e_coco.py' \
--output-dir 'work-dir/browse_dataset'
- Use
config
fileconfigs/yolov5/yolov5_s-v61_syncbn_8xb16-300e_coco.py
to visualize the picture. The picture will pop up and display directly. Each picture lasts for10
seconds. At the same time, it will be saved to the directorywork dir/browse_ dataset
:
python tools/analysis_tools/browse_dataset.py 'configs/yolov5/yolov5_s-v61_syncbn_8xb16-300e_coco.py' \
--output-dir 'work-dir/browse_dataset' \
--show-interval 10
- Use
config
fileconfigs/yolov5/yolov5_s-v61_syncbn_8xb16-300e_coco.py
to visualize the picture. The picture will pop up and display directly. Each picture lasts for10
seconds and the picture will not be saved:
python tools/analysis_tools/browse_dataset.py 'configs/yolov5/yolov5_s-v61_syncbn_8xb16-300e_coco.py' \
--show-interval 10
- Use
config
fileconfigs/yolov5/yolov5_s-v61_syncbn_8xb16-300e_coco.py
to visualize the picture. The picture will not pop up directly, but only saved to the directorywork dir/browse_ dataset
:
python tools/analysis_tools/browse_dataset.py 'configs/yolov5/yolov5_s-v61_syncbn_8xb16-300e_coco.py' \
--output-dir 'work-dir/browse_dataset' \
--not-show
the tools/
directory also contains script to convert the balloon
dataset (A small dataset is only for beginner use) into COCO format.
For a detailed description of this script, please refer to the "Dataset Preparation" section in From getting started to deployment with YOLOv5.
python tools/dataset_converters/balloon2coco.py
tools/misc/download_dataset.py
supports downloading datasets such as COCO
, VOC
, LVIS
and Balloon
.
python tools/misc/download_dataset.py --dataset-name coco2017
python tools/misc/download_dataset.py --dataset-name voc2007
python tools/misc/download_dataset.py --dataset-name lvis
python tools/misc/download_dataset.py --dataset-name balloon [--save-dir ${SAVE_DIR}] [--unzip]
The three scripts under the tools/
directory can help users convert the keys in the official pre-trained model of YOLO to the format of MMYOLO, and use MMYOLO to fine tune the model.
Take conversion yolov5s.pt
as an example:
- Clone the official YOLOv5 code to the local (currently the maximum supported version is
v6.1
):
git clone -b v6.1 https://github.com/ultralytics/yolov5.git
cd yolov5
- Download official weight file:
wget https://github.com/ultralytics/yolov5/releases/download/v6.1/yolov5s.pt
- Copy file
tools/model_converters/yolov5_to_mmyolo.py
to the path of YOLOv5 official code clone:
cp ${MMDET_YOLO_PATH}/tools/model_converters/yolov5_to_mmyolo.py yolov5_to_mmyolo.py
- Conversion
python yolov5_to_mmyolo.py --src ${WEIGHT_FILE_PATH} --dst mmyolov5.pt
The converted mmyolov5.pt
can be used by MMYOLO. The official weight conversion of YOLOv6 is also used in the same way.
The conversion of YOLOX model does not need to download the official YOLOX code, just download the weight.
Take conversion yolox_s.pth
as an example:
- Download official weight file:
wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_s.pth
- Conversion
python tools/model_converters/yolox_to_mmyolo.py --src yolox_s.pth --dst mmyolox.pt
The converted mmyolox.pt
can be used by MMYOLO.