Open kuro0ni opened 7 years ago
@Zehaos Hi i get the same issue above @br3ach3r mentioned. could you please correct us if we are doing something wrong ?
I'm having this issue too. I think it's related to a growing graph every time the 'read_tensor_from_image_file' function is called. I found this question on StackOverflow. The solution posted there doesn't work for me, but it may help someone else.
Edit: I found a solution here which works for me. You want to wrap the body of the read_tensor_from_image_file()
function with a with tf.Graph().as_default():
. So your code should look something like this:
def read_tensor_from_image_file(file_name, input_height=299, input_width=299,
input_mean=0, input_std=255):
with tf.Graph().as_default():
input_name = "file_reader"
output_name = "normalized"
file_reader = tf.read_file(file_name, input_name)
image_reader = tf.image.decode_jpeg(file_reader, channels = 3,
name='jpeg_reader')
float_caster = tf.cast(image_reader, tf.float32)
dims_expander = tf.expand_dims(float_caster, 0)
resized = tf.image.resize_bilinear(dims_expander, [input_height, input_width])
normalized = tf.divide(tf.subtract(resized, [input_mean]), [input_std])
sess = tf.Session()
result = sess.run(normalized)
return result
Hope this helps.
I followed this tutorial to retrain Mobilenet and i am calling the Predict() function in a loop. I printed out the how much time it takes one prediction to happen and it starts around 0.6 seconds and goes up gradually. My PC specs are i7 4790, GTX 1070, 16 GB RAM.
Here's the python script using the model.