First, when i tried LabelImage example with inception model ver 5, everything was good.
Then i tried with an older inception model ( ver3 ) and i saw that both model have different input and output.
In ver5, our input tensor name is : "Input" , with dtype = FLOAT.
In ver 3, our input tensor name is "DecodeJpeg/contents" , with dtype = STRING.
So i change LabelExample example with new name for both input and output : Tensor result = s.runner().feed("input", string_tensor_image).fetch("output") >> s.runner().feed("DecodeJpeg/contents", image).fetch("softmax") .
Also, i changed create new Image tensor for STRING type :
Tensor float_tensor = s.runner().fetch(output.op().name()).run().get(0);
byte[] bytes = new byte[float_tensor.numBytes()*64];
ByteBuffer buffer = ByteBuffer.wrap(bytes);
res.writeTo(buffer);
long[] shape = {};
Tensor string_tensor = Tensor.create(DataType.STRING, shape, buffer);
return string_tensor;
It looked good when i printed both tensor :
FLOAT tensor with shape [1, 224, 224, 3]
STRING tensor with shape []
But after feeding to the graph, i get this error :
Exception in thread "main" java.lang.IllegalArgumentException: Invalid JPEG data, size 0
[[Node: DecodeJpeg = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"]
I have tried everything i can, but no results. How can i fix it ? This is both inception model ver3 and ver 5 :
ver5 : https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip
ver 3 : http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz