The following example shows how to evaluate AI Models for RZ/V2H. The created inference will be able to run on the DRP-AI (INT8). The inference output may not be accurate because the training needs to be done to further calibrate the AI Model.
For this demo we are using the Darknet YoloV2 VOC.
Code Block |
---|
mkdir data docker run -it --name drp-ai_tvm_v2h_container_${USER} -v $(pwd)/data:/drp-ai_tvm/data drp-ai_tvm_v2h_image_${USER} |
Code Block |
---|
# Added the following paths to use the TVM Scripts PYTHONPATH=/drp-ai_tvm/tvm/python:/drp-ai_tvm/tutorials/ # Create Symbolic links for the following bash scripts # These are requried to run TVM translator ln -s /drp-ai_tvm/tutorials/run_* |
Code Block |
---|
wget https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolov2-voc.cfg wget https://pjreddie.com/media/files/yolov2-voc.weights |
Code Block |
---|
cp /drp-ai_tvm/how-to/sample_app/docs/object_detection/yolo/yolo.ini . |
Code Block |
---|
python3 ../scripts/convert_to_pytorch.py yolov2 |
Code Block |
---|
python3 ../scripts/convert_to_onnx.py yolov2 |
Code Block |
---|
cp /drp-ai_tvm/tutorials/compile_onnx_model_quant.py /drp-ai_tvm/tutorials/compile_onnx_model_yolov2.py |
Code Block | ||
---|---|---|
| ||
mean = [0.485, 0.456, 0.406] stdev = [0.229, 0.224, 0.225] |
Code Block | ||
---|---|---|
| ||
config.shape_in = [1, 480, 640, 3] mean = [0.0, 0.0, 0.0] stdev = [1.0, 1.0, 1.0] |
Code Block | ||
---|---|---|
| ||
# Configure TVM DRP-AI Preprocessor Camera/Image input shape sed -i 's/^.*config.shape_in.*$/ config.shape_in = [1, 480, 640, 3]/' /drp-ai_tvm/tutorials/compile_onnx_model_yolov2.py # Change the default TVM DRP-AI Preprocessor mean and stdev to YoloV2 sed -i 's/mean\s*=\s*\[[0-9., ]*\]/mean = [0.0, 0.0, 0.0]/' /drp-ai_tvm/tutorials/compile_onnx_model_yolov2.py sed -i 's/stdev\s*=\s*\[[0-9., ]*\]/stdev = [1.0, 1.0, 1.0]/' /drp-ai_tvm/tutorials/compile_onnx_model_yolov2.py |
Code Block |
---|
python3 compile_onnx_model_yolov2.py \ ./d-yolov2.onnx \ -t $SDK \ -d $TRANSLATOR \ -c $QUANTIZER \ -i input1 \ -s 1,3,416,416 \ -o yolov2_onnx \ -v 100 |
Table of Contents | ||
---|---|---|
|