Skip to content

Latest commit

 

History

History
259 lines (190 loc) · 8.91 KB

README_EN.md

File metadata and controls

259 lines (190 loc) · 8.91 KB

This repo is available in Japanese.
This repository is used by YOLOXとOpenVINOで学習から高速推論までやってみた(coming soon)

YOLOX is an anchor-free version of YOLO, with a simpler design but better performance! It aims to bridge the gap between research and industrial communities.The benchmark was shown like this. For more details, please refer to our report on Arxiv.

CVAT is a free tool that provides an automatic annotation function that allows the system to automatically add metadata to images from a pre-defined database. CVAT uses AI to automatically annotate images and videos using models such as yolo.
In this repository, we use the PASCAL VOC 1.1 dataset generated by CVAT.
For more information on how to set up and use CVAT, please refer to CVATの自動アノテーション機能を使ってみた on Qiita.

Components

  • CVATDatasets_ML.ipynb
    In this notebook, using the dataset created by CVAT for training.
    This notebook uses the latest trained model (ver 0.1.1) as of 9/1/2021 (see cell 56).

  • add_voc.py
    This is a script to add directory for training datasets generated from CVAT with YOLOX.

How to Use CVATDatasets_ML.ipynb?

Basically, if you run it with Google Colab, the process from training to validation will be completed, but you may need to change some part of the notebook.

データセットのダウンロード / Download your Dataset

Download your dataset from CVAT. Use the "Open Task" --> "Open Job" --> "Menu (hamburger button)" --> "Export as a dataset" --> "PASCAL VOC 1.1" export format.
Upload the exported zip file to DropBox, etc., and write the shared link in the following "URL". Alternatively, upload the file to the default directory of Google Colab (the directory where sample_data is located). The file name should be converted to BDD.zip, and !curl -L "URL" > BDD.zip should be commented out.

クラス名の変更 / Change the Classes Make sure you change the classes based on what your dataset. To ensure that the training process will function as intended, write the classes in lowercase with no whitespace.
CLASSES = (
  "malitozzo",
  "curry bread",
  "hot dog",
  "krone",
  "melon bread"
)
トレーニング済みの重みファイルをダウンロード / Download Pretrained Weights Please change the link to download the latest trained model as appropriate. It should work fine by default.
!wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_s.pth
トレーニング / Train the Model Change the number of EPOCH_NUM as you need.
EPOCH_NUM = 150
モデルをテストする / Test the Model Change the test image as you need.
TEST_IMAGE_PATH = "/content/drive/MyDrive/YOLOX-s/IMG.jpg"
トレーニング済みモデルをGoogle Driveにエクスポートする / Export Trained Weights to Your Google Drive The following is specified as the copy destination for the model, but you can change it.
/content/drive/MyDrive/YOLOX-s

The following is mostly as it was in the original--------------------

Quick Start

Installation

Step1. Install YOLOX.

git clone git@github.com:Megvii-BaseDetection/YOLOX.git
cd YOLOX
pip3 install -U pip && pip3 install -r requirements.txt
pip3 install -v -e .  # or  python3 setup.py develop

Step2. Install apex.

# skip this step if you don't want to train model.
git clone https://github.com/NVIDIA/apex
cd apex
pip3 install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./

Step3. Install pycocotools.

pip3 install cython; pip3 install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
Demo

Step1. Download a pretrained model from the benchmark table.

Step2. Use either -n or -f to specify your detector's config. For example:

python tools/demo.py image -n yolox-s -c /path/to/your/yolox_s.pth.tar --path assets/dog.jpg --conf 0.25 --nms 0.45 --tsize 640 --save_result --device [cpu/gpu]

or

python tools/demo.py image -f exps/default/yolox_s.py -c /path/to/your/yolox_s.pth.tar --path assets/dog.jpg --conf 0.25 --nms 0.45 --tsize 640 --save_result --device [cpu/gpu]

Demo for video:

python tools/demo.py video -n yolox-s -c /path/to/your/yolox_s.pth.tar --path /path/to/your/video --conf 0.25 --nms 0.45 --tsize 640 --save_result --device [cpu/gpu]
Reproduce our results on COCO

Step1. Prepare COCO dataset

cd <YOLOX_HOME>
ln -s /path/to/your/COCO ./datasets/COCO

Step2. Reproduce our results on COCO by specifying -n:

python tools/train.py -n yolox-s -d 8 -b 64 --fp16 -o
                         yolox-m
                         yolox-l
                         yolox-x
  • -d: number of gpu devices
  • -b: total batch size, the recommended number for -b is num-gpu * 8
  • --fp16: mixed precision training

Multi Machine Training

We also support multi-nodes training. Just add the following args:

  • --num_machines: num of your total training nodes
  • --machine_rank: specify the rank of each node

When using -f, the above commands are equivalent to:

python tools/train.py -f exps/default/yolox-s.py -d 8 -b 64 --fp16 -o
                         exps/default/yolox-m.py
                         exps/default/yolox-l.py
                         exps/default/yolox-x.py
Evaluation

We support batch testing for fast evaluation:

python tools/eval.py -n  yolox-s -c yolox_s.pth.tar -b 64 -d 8 --conf 0.001 [--fp16] [--fuse]
                         yolox-m
                         yolox-l
                         yolox-x
  • --fuse: fuse conv and bn
  • -d: number of GPUs used for evaluation. DEFAULT: All GPUs available will be used.
  • -b: total batch size across on all GPUs

To reproduce speed test, we use the following command:

python tools/eval.py -n  yolox-s -c yolox_s.pth.tar -b 1 -d 1 --conf 0.001 --fp16 --fuse
                         yolox-m
                         yolox-l
                         yolox-x
Tutorials

Deployment

  1. MegEngine in C++ and Python
  2. ONNX export and an ONNXRuntime
  3. TensorRT in C++ and Python
  4. ncnn in C++ and Java
  5. OpenVINO in C++ and Python

Third-party resources

Cite YOLOX

If you use YOLOX in your research, please cite the Megvii Team's work by using the following BibTeX entry:

 @article{yolox2021,
  title={YOLOX: Exceeding YOLO Series in 2021},
  author={Ge, Zheng and Liu, Songtao and Wang, Feng and Li, Zeming and Sun, Jian},
  journal={arXiv preprint arXiv:2107.08430},
  year={2021}
}

-----------------------------------------------

License

YOLOX is distributed under the Apache License 2.0.

references