huajsj commented on a change in pull request #4887: [VTA] YoloV3 Support
URL: https://github.com/apache/incubator-tvm/pull/4887#discussion_r384064866
 
 

 ##########
 File path: vta/tutorials/frontend/deploy_detection_on_vta.py
 ##########
 @@ -0,0 +1,334 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+Deploy Pretrained Vision Detection Model from Darknet on VTA
+================================================
+**Author**: `Hua Jiang <https://github.com/huajsj>`_
+
+This tutorial provides an end-to-end demo, on how to run Darknet YoloV3-tiny
+inference onto the VTA accelerator design to perform Image detection tasks.
+It showcases Relay as a front end compiler that can perform quantization (VTA
+only supports int8/32 inference) as well as graph packing (in order to enable
+tensorization in the core) to massage the compute graph for the hardware 
target.
+"""
+
+######################################################################
+# Install dependencies
+# --------------------
+# To use the autotvm package in tvm, we need to install some extra 
dependencies.
+# (change "3" to "2" if you use python2):
+#
+# .. code-block:: bash
+#
+# pip3 install "Pillow<7"
+#
+# YOLO-V3-tiny Model with Darknet parsing have dependancy with CFFI and CV2 
library,
+# we need to install CFFI and CV2 before executing this script.
+# 
+# pip3 install "Pillow<7"
+#
+# pip3 install cffi
+# pip3 install opencv-python
+#
+# Now return to the python code. Import packages.
+
+from __future__ import absolute_import, print_function
+
+import sys
+import os
+import time
+import tvm
+import vta
+import numpy as np
+import matplotlib.pyplot as plt
+import tvm.relay.testing.yolo_detection
+import tvm.relay.testing.darknet
+
+from ctypes import *
+from tvm import relay
+from tvm.contrib import graph_runtime
+from tvm.contrib.download import download_testdata
+from tvm.contrib import graph_runtime, util
+from tvm.relay.testing.darknet import __darknetffi__
+
+
+from vta.testing import simulator
+from vta.top import graph_pack
+from tvm import rpc, autotvm, relay
+# Make sure that TVM was compiled with RPC=1
+assert tvm.runtime.enabled("rpc")
+
+######################################################################
+# Download yolo net configure file, weight file, darknet library file based on
+# Model Name
+# --------------------------
+MODEL_NAME = 'yolov3-tiny'
+REPO_URL = 'https://github.com/dmlc/web-data/blob/master/darknet/'
+
+cfg_path = 
download_testdata('https://github.com/pjreddie/darknet/blob/master/cfg/' 
+                             + MODEL_NAME + '.cfg' + '?raw=true', 
+                             MODEL_NAME + '.cfg', 
+                             module="darknet")
+weights_path = download_testdata('https://pjreddie.com/media/files/' 
 
 Review comment:
   this format is reference existing tutorial 
https://docs.tvm.ai/tutorials/frontend/from_darknet.html, would be better to 
keep same style.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to