- To learn more about DAMO-YOLO visit the official repository
- docker (docker installation instructions)
- nvidia-container-toolkit (installation instructions)
NOTE: In case you are using the Hailo Software Suite docker, make sure to run all of the following instructions outside of that docker.
- Build the docker image:
cd hailo_model_zoo/training/damoyolo docker build --build-arg timezone=`cat /etc/timezone` -t damoyolo:v0 .
the following optional arguments can be passed via --build-arg:timezone- a string for setting up timezone. E.g. "Asia/Jerusalem"user- username for a local non-root user. Defaults to 'hailo'.group- default group for a local non-root user. Defaults to 'hailo'.uid- user id for a local non-root user.gid- group id for a local non-root user.
* This command will build the docker image with the necessary requirements using the Dockerfile exists in damoyolo directory. - Start your docker:
docker run --name "your_docker_name" -it --gpus all --ipc=host -v /path/to/local/data/dir:/path/to/docker/data/dir damoyolo:v0
docker runcreate a new docker container.--name <your_docker_name>name for your container.-itruns the command interactively.--gpus allallows access to all GPUs.--ipc=hostsets the IPC mode for the container.-v /path/to/local/data/dir:/path/to/docker/data/dirmaps/path/to/local/data/dirfrom the host to the container. You can use this command multiple times to mount multiple directories.damoyolo:v0the name of the docker image.
- Train your model:Once the docker is started, you can start training your model.
- Prepare your custom dataset (must be coco format) - Follow the steps described here.
- Modify
num_classesandclass_namesin the configuration file, for exampledamoyolo_tinynasL20_T.py - Use
self.train.batch_size/self.train.total_epochsin the configuration file to modify the batch_size and number of epochs - Update the symbolic link to your dataset: ln -sfn /your/coco/like/dataset/path datasets/coco
- Start training - The following command is an example for training a damoyolo_tinynasL20_T model.
python tools/train.py -f configs/damoyolo_tinynasL20_T.py configs/damoyolo_tinynasL25_S.py configs/damoyolo_tinynasL35_M.pyconfigs/damoyolo_tinynasL20_T.py- configuration file of the DAMO-YOLO variant you would like to train. In order to change the number of classes make sure you updatenum_classesandclass_namesin this file.
- Export to ONNX:In order to export your trained DAMO-YOLO model to ONNX run the following script:
python tools/converter.py -f configs/damoyolo_tinynasL20_T.py -c /path/to/trained/model.pth --batch_size 1 --img_size 640 # export at 640x640 with batch size 1
You can generate an HEF file for inference on Hailo-10H from your trained ONNX model.
In order to do so you need a working model-zoo environment.
Choose the corresponding YAML from our networks configuration directory, i.e.
hailo_model_zoo/cfg/networks/damoyolo_tinynasL20_T.yaml, and run compilation using the model zoo:hailomz compile --ckpt damoyolo_tinynasL20_T.onnx --calib-path /path/to/calibration/imgs/dir/ --yaml path/to/damoyolo/variant.yaml --start-node-names name1 name2 --end-node-names name1
--ckpt- path to your ONNX file.--calib-path- path to a directory with your calibration images in JPEG/png format--yaml- path to your configuration YAML file.--start-node-namesand--end-node-names- node names for customizing parsing behavior (optional).- The model zoo will take care of adding the input normalization to be part of the model.
More details about YAML files are presented here.