Note: The purpose of this repo is to serve as a sample only and should not be considered production quality. It may have future rapid iterations and additions of other algorithms/approaches for use with Azure ML. Thank you for your patience.
The algorithm used here is Darknet Tiny YOLOv4.
- Python 3.6+ installed locally
- Recommend using a virtual environment or conda environment for this project to keep everything contained
- Azure ML Workspace
- Labeled data (YOLO format)
- Convert to YOLO format as needed
- Clone this repository.
- Calculate anchor boxes.
- You may find an anchor box calculator script here.
- Create
.azureml
folder in the root of this repository and downloadconfig.json
from Azure ML Workspace resource in the Azure Portal to this folder. - Install the required packages.
pip install -r requirements_local.txt
- Run Jupyter and then navigate to the given URL in a browser.
jupyter notebook
-
Open
Train.ipynb
and follow along (runs may be monitored from Azure ML Studio - also found at https://ml.azure.com).- Change the
num_classes
andanchors
in the Train script writing cell. - Update the hyperparameter sweep values for your scenario to experiment.
- Update the
epochs
for training to experiment.
- Change the
-
Download the Darknet
.weights
and config,.cfg
file from Azure ML Workspace runoutputs
folder. -
Convert to ONNX
- Use this script to convert Darknet weights to ONNX (note, this script is in a different repo). e.g.:
python yolo_to_onnx.py --model yolov4-tiny-custom_final
- Use the
helper_scripts/demo_onnx.py
to predict with your model on a single image. - e.g.:
python helper_scripts/onnx_export_demo/demo_onnx.py --model yolov4-tiny-custom_final.onnx --image mytestimage.jpg --labels obj.names --thresh 0.7`
- Automatcially calcuate anchor boxes
- Support full sized YOLOv4
- Add hyperparameters and class number as params in
train.ipynb
Jupyter notebook - Show converting to ONNX