一 tensorflow安装(安装过的跳过)
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ tensorflow==2.0.0b1
二 下载所需文件
elephant-299.jpg
classify_image_graph_def-with_shapes.pb imagenet_2012_challenge_label_map_proto.pbtxt
imagenet_synset_to_human_label_map.txt
(下载网站:
https://github.com/dmlc/web-data/raw/main/tensorflow/models/InceptionV1/)
文件保存路径:elephant-299.jpg、 imagenet_2012_challenge_label_map_proto.pbtxt 、imagenet_synset_to_human_label_map.txt 保存在/home5/yunji.he/.tvm_test_data/data目录下。classify_image_graph_def-with_shapes.pb文件保存在/home5/yunji.he/.tvm_test_data/tf/InceptionV1
三 测试
(1)导入头文件
import tvm
from tvm import te
from tvm import relay
# os and numpy
import numpy as np
import os.path
# Tensorflow imports
import tensorflow as tf
try:
tf_compat_v1 = tf.compat.v1
except ImportError:
tf_compat_v1 = tf
# Tensorflow utility functions
import tvm.relay.testing.tf as tf_testing
# Base location for model related files.
repo_base = "https://github.com/dmlc/web-data/raw/main/tensorflow/models/InceptionV1/"
# Test image
img_name = "elephant-299.jpg"
image_url = os.path.join(repo_base, img_name)
(2)
model_name = "classify_image_graph_def-with_shapes.pb"
model_url = os.path.join(repo_base, model_name)
# Image label map
map_proto = "imagenet_2012_challe