报错ValueError: could not convert string to float: 'C:/Users/Administrator/Desktop/se//12.21/FV-USM/Published_database_FV-USM_Dec2013/1st_session/extractedvein/vein001_1/01.jpg'
以下是我的代码
```#!/usr/bin/env python
-*- coding:utf-8 -*-
import tensorflow as tf
from PIL import Image
import model
import numpy as np
import os
def get_one_image():
i=1
n=1
k=1
i = str(i)
n = str(n)
k = str(k)
a = i.zfill(3)
b = n.zfill(1)
c = k.zfill(2)
files='C:/Users/Administrator/Desktop/se//12.21/FV-USM/Published_database_FV-USM_Dec2013/1st_session/extractedvein/vein' + a + '_' + b + '/' + c + '.jpg'
# image=image.resize([60,175])
# image=np.array(image)
return files
def evaluate_one_image():
image_array = get_one_image()
with tf.Graph().as_default():
BATCH_SIZE=1
N_CLASS=123
image = tf.image.decode_jpeg(image_array, channels=1)
image = tf.image.resize_image_with_crop_or_pad(image,60, 175)
image = tf.image.per_image_standardization(image) ###图片调整完成
# image=tf.cast(image,tf.string)
# image1 = tf.image.decode_jpeg(image, channels=1)
# image1 = tf.image.resize_image_with_crop_or_pad(image1, image_w, image_h)
#image1 = tf.image.per_image_standardization(image) ###图片调整完成
#image=tf.image.per_image_standardization(image)
image = tf.cast(image, tf.float32)
image=tf.reshape(image,[1,60,175,1])
logit = model.inference(image, BATCH_SIZE, N_CLASS)
logit=tf.nn.softmax(logit) # 因为 inference 的返回没有用激活函数,所以在这里对结果用softmax 激活。但是为什么要激活??
x=tf.placeholder(tf.float32,shape=[60,175,1])
logs_model_dir='C:/Users/Administrator/Desktop/python的神经网络/model/'
saver=tf.train.Saver()
with tf.Session() as sess:
print("从指定路径加载模型。。。")
ckpt=tf.train.get_checkpoint_state(logs_model_dir)
if ckpt and ckpt.model_checkpoint_path:
global_step=ckpt.model_checkpoint_path.split('/')[-1].split('-')[-1]
saver.restore(sess,ckpt.model_checkpoint_path)
print('模型加载成功,训练步数为 %s'%global_step)
else:
print('模型加载失败,,,,文件没有找到')
###IMG = sess.run(image)
prediction=sess.run(logit,feed_dict={x:image_array})
max_index=np.argmax(prediction)
print(max_index)
evaluate_one_image()