我一直在尝试使用谷歌发布的预训练的inception_resnet_v2模型.我正在使用他们的模型定义(https://github.com/tensorflow/models/blob/master/slim/nets/inception_resnet_v2.py)并给出检查点(http://download.tensorflow.org/models/inception_resnet_v2_2016_08_30.tar.gz)在tensorflow中加载模型,如下所示[下载提取检查点文件并下载示例图像dog.jpg和panda.jpg来测试此代码] –
import tensorflow as tf
slim = tf.contrib.slim
from PIL import Image
from inception_resnet_v2 import *
import numpy as np
checkpoint_file = 'inception_resnet_v2_2016_08_30.ckpt'
sample_images = ['dog.jpg', 'panda.jpg']
#Load the model
sess = tf.Session()
arg_scope = inception_resnet_v2_arg_scope()
with slim.arg_scope(arg_scope):
logits, end_points = inception_resnet_v2(input_tensor, is_training=False)
saver = tf.train.Saver()
saver.restore(sess, checkpoint_file)
for image in sample_image