- To learn more about FCN look here
- 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/fcn docker build -t fcn:v0 --build-arg timezone=`cat /etc/timezone` .
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.
- Start your docker:
docker run --name "your_docker_name" -it --gpus all -u "username" --ipc=host -v /path/to/local/data/dir:/path/to/docker/data/dir fcn:v0
docker runcreate a new docker container.--name <docker-name>name for your container.-u <username>same username as used for building the image.-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.fcn:v0the name of the docker image.
- Prepare your data:Data is expected to be in coco format, and by default should be in /workspace/data/<dataset_name>.The expected structure is as follows:
/workspace |-- mmsegmentation `-- |-- data `-- cityscapes |-- gtFine | | -- train | | | -- aachem | | | -- | -- *.png | | ` -- ... | ` -- test | | -- berlin | | -- | -- *.png | ` -- ... `-- leftImg8bit | -- train | -- | -- aachem | -- | -- | -- *.png | -- ` -- ... ` -- test | -- berlin | -- | -- *.png ` -- ...more information can be found here - Training:Configure your model in a .py file. We'll use /workspace/mmsegmentation/configs/fcn/fcn8_r18_hailo.py in this guide.start training with the following command:
cd /workspace/mmsegmentation ./tools/dist_train.sh configs/fcn/fcn8_r18_hailo.py 2
Where 2 is the number of GPUs used for training. - Exporting to onnxAfter training, run the following command:
cd /workspace/mmsegmentation python ./tools/pytorch2onnx.py configs/fcn/fcn8_r18_hailo.py --checkpoint ./work_dirs/fcn8_r18_hailo/iter_59520.pth --shape 1024 1920 --out_name fcn.onnx
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/fcn8_resnet_v1_18.yaml, and run compilation using the model zoo:hailomz compile --ckpt fcn.onnx --calib-path /path/to/calibration/imgs/dir/ --yaml path/to/fcn8_resnet_v1_18.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.
Note
More details about YAML files are presented here.