import tensorflow as tf
import requests
import os
import tarfile
inception_url="http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz";
inception_url_dir="model/";
if not os.path.exists(inception_url_dir):
os.makedirs(inception_url_dir);
inception_url_dir_file=os.path.join(inception_url_dir,inception_url.split("/")[-1]);
if not os.path.exists(inception_url_dir_file):
print("Download:",inception_url.split("/")[-1]);
r=requests.get(inception_url,stream=True);
with open(inception_url_dir_file,'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk:
f.write(chunk);
print("finished!!!");
tarfile.open(inception_url_dir_file,"r:gz").extractall(inception_url_dir);
inception_log="inception_log";
if not os.path.exists(inception_log):
os.makedirs(inception_log);
model_pb_path=os.path.join(inception_url_dir,"classify_image_graph_def.pb");
with tf.Session() as sess:
with tf.gfile.GFile(model_pb_path,"rb") as f:
graph_def=tf.GraphDef();
graph_def.ParseFromString(f.read());
tf.import_graph_def(graph_def);
writer=tf.summary.FileWriter(inception_log,sess.graph);
writer.close();
下载Inception
最新推荐文章于 2020-01-31 18:27:20 发布