mdietrichstein / tensorflow-open_nsfw

Tensorflow Implementation of Yahoo's Open NSFW Model
Other
430 stars 136 forks source link

dtype for the input placeholder #15

Closed aayux closed 6 years ago

aayux commented 6 years ago

I exported the model serving with export_savedmodel.py and then wrote a Java program for deploying the model on end devices. The main part of the code is as follows:

SavedModelBundle savedModelBundle = SavedModelBundle.load( ... );
Tensor result = savedModelBundle.session().runner()
                .feed("input", normalizedImageTensor) // error here
                .fetch("predictions")
                .run().get(0);

normalizedImageTensor is the input image loaded and transformed as in __tf_jpeg_process and then casted to a tensor.

The error pertaining to the commented line is

Exception in thread "main" java.lang.IllegalArgumentException: Expects arg[0] to be string but float is provided
    at org.tensorflow.Session.run(Native Method)
    at org.tensorflow.Session.access$100(Session.java:48)
    at org.tensorflow.Session$Runner.runHelper(Session.java:298)
    at org.tensorflow.Session$Runner.run(Session.java:248)
    at com.paralleldots.lava.api.main(api.java:59)

This is saying that normalizedImageTensor is of type string.

What then is the dtype for the input placeholder in your actual graph? What kind of input is expected?

aayux commented 6 years ago

The default input_type when building the model graph is InputType.BASE64_JPEG as seen in this line which results in self.input being initialized to type tf.string.