|
| 1 | +# YOLO V3 Darknet Conversion to Keras |
| 2 | + |
| 3 | +The network definition and weights come from [darknet |
| 4 | +website](https://pjreddie.com/darknet/yolo/). It is converted to the keras model using [this](https://github.com/qqwweee/keras-yolo3) repository. |
| 5 | + |
| 6 | +It has been converted to onnx format |
| 7 | +using [tf2onnx](https://github.com/onnx/tensorflow-onnx). |
| 8 | + |
| 9 | +## Executing the model |
| 10 | + |
| 11 | +All commands should be run from the root of the model zoo directory. |
| 12 | + |
| 13 | +1.Compile a local image of `autoware/model-zoo-tvm-cli` |
| 14 | + |
| 15 | +```bash |
| 16 | +$./scripts/tvm_cli/build.sh |
| 17 | +``` |
| 18 | + |
| 19 | +2.Compile the model by running the TVM CLI script in a docker container |
| 20 | + |
| 21 | +```bash |
| 22 | +$ MODEL_DIR=$(pwd)/perception/camera_obstacle_detection/yolo_v3/tensorflow_fp32_coco/ |
| 23 | +$ export MODEL_DIR |
| 24 | +$ docker run \ |
| 25 | + -it --rm \ |
| 26 | + -v ${MODEL_DIR}:${MODEL_DIR} -w ${MODEL_DIR} \ |
| 27 | + -u $(id -u ${USER}):$(id -g ${USER}) \ |
| 28 | + autoware/model-zoo-tvm-cli:local \ |
| 29 | + compile \ |
| 30 | + --config ${MODEL_DIR}/definition.yaml \ |
| 31 | + --output_path ${MODEL_DIR}/execute_model/build |
| 32 | +``` |
| 33 | + |
| 34 | +3.Compile the c++ pipeline |
| 35 | + |
| 36 | +```bash |
| 37 | +$ docker run \ |
| 38 | + -it --rm \ |
| 39 | + -v ${MODEL_DIR}:${MODEL_DIR} -w ${MODEL_DIR}/execute_model/build \ |
| 40 | + -u $(id -u ${USER}):$(id -g ${USER}) \ |
| 41 | + --entrypoint "" \ |
| 42 | + autoware/model-zoo-tvm-cli:local \ |
| 43 | + bash -c "cmake .. && make -j" |
| 44 | +``` |
| 45 | + |
| 46 | +4.Download a sample image and copy some files needed for decoding detections |
| 47 | + |
| 48 | +```bash |
| 49 | +$ curl https://raw.githubusercontent.com/pjreddie/darknet/master/data/dog.jpg \ |
| 50 | + > ${MODEL_DIR}/execute_model/build/test_image_0.jpg |
| 51 | +$ cp ${MODEL_DIR}/model_files/labels.txt ${MODEL_DIR}/execute_model/build/ |
| 52 | +$ cp ${MODEL_DIR}/model_files/anchors.csv ${MODEL_DIR}/execute_model/build/ |
| 53 | +``` |
| 54 | + |
| 55 | +5.Run the detection pipeline inside a docker container. The output result can be obtained in two ways: |
| 56 | + |
| 57 | +- **Save as an image**: saves the result of the pipeline as an image file in the build directory, the filename `output.jpg` can be changed in the command if needed: |
| 58 | + |
| 59 | + ```bash |
| 60 | + $ docker run \ |
| 61 | + -it --rm \ |
| 62 | + --net=host \ |
| 63 | + -v ${MODEL_DIR}:${MODEL_DIR} \ |
| 64 | + -w ${MODEL_DIR}/execute_model/build \ |
| 65 | + --entrypoint "" \ |
| 66 | + autoware/model-zoo-tvm-cli:local \ |
| 67 | + ./execute_model output.jpg |
| 68 | + ``` |
| 69 | + |
| 70 | +- **Display in a X11 window**: X draw calls are forwarded to the host so the detection results can be displayed in a X11 window. |
| 71 | + |
| 72 | + ```bash |
| 73 | + $ docker run \ |
| 74 | + -it --rm \ |
| 75 | + -v /tmp/.X11-unix:/tmp/.X11-unix:rw \ |
| 76 | + -v ${HOME}/.Xauthority:${HOME}/.Xauthority:rw \ |
| 77 | + -e XAUTHORITY=${HOME}/.Xauthority \ |
| 78 | + -e DISPLAY=$DISPLAY \ |
| 79 | + --net=host \ |
| 80 | + -v ${MODEL_DIR}:${MODEL_DIR} \ |
| 81 | + -w ${MODEL_DIR}/execute_model/build \ |
| 82 | + --entrypoint "" \ |
| 83 | + autoware/model-zoo-tvm-cli:local \ |
| 84 | + ./execute_model |
| 85 | + ``` |
| 86 | + |
| 87 | +For more information about getting the TVM docker image, see the TVM CLI |
| 88 | +[documentation](../../../../scripts/tvm_cli/README.md). |
0 commit comments