Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to input an image to image_classifier running on tensorflow serving #6

Open
gr8Adakron opened this issue May 10, 2018 · 2 comments

Comments

@gr8Adakron
Copy link

gr8Adakron commented May 10, 2018

> My tensorflow image_classifier is running on tf_hub_serving right with the help of epigramai medium tutorial

Successfully, I was able to run the sample model of the addition of two number with that tutorial. With this client program.

import logging
from predict_client.prod_client import ProdClient
logging.basicConfig(level=logging.DEBUG,
                    format='%(asctime)s - %(levelname)s - %(name)s - %(message)s')
# In each file/module, do this to get the module name in the logs
logger = logging.getLogger(__name__)

# Make sure you have a model running on localhost:9000
host = 'localhost:9000'
model_name = 'simple'
model_version = 1

client = ProdClient(host, model_name, model_version)
req_data = [{'in_tensor_name': 'a', 'in_tensor_dtype': 'DT_INT32', 'data': 2}]
prediction = client.predict(req_data, request_timeout=10)
logger.info('Prediction: {}'.format(prediction))

And now I have trained image_classifier with the help of this tensorflow script retrain.py.
The model has been trained successfully, and its running on tensorflow serving but my real question is how to pass an image so that it will make a prediction? I edited that working client code for addition of two number but it is returning error.

The model is running on localhost:9001 for now.
The image_classifier_serving_client_code is:


import logging
import cv2
from predict_client.prod_client import ProdClient
logging.basicConfig(level=logging.DEBUG,
                    format='%(asctime)s - %(levelname)s - %(name)s - %(message)s')
# In each file/module, do this to get the module name in the logs
logger = logging.getLogger(__name__)

# Make sure you have a model running on localhost:9000
host = 'localhost:9001'
model_name = 'off_shoulder'
model_version = 1525854035

client = ProdClient(host, model_name, model_version)
img    = cv2.imread("temp.jpg", cv2.IMREAD_COLOR)
req_data = [{'in_tensor_name': 'image', 'in_tensor_dtype': 'DT_UINT8', 'data': img}]

prediction = client.predict(req_data, request_timeout=10)
logger.info('Prediction: {}'.format(prediction))


The error generated is:

2018-05-10 10:59:04,435 - INFO - ProdClient - Sending request to tfserving model
2018-05-10 10:59:04,435 - INFO - ProdClient - Host: localhost:9001
2018-05-10 10:59:04,436 - INFO - ProdClient - Model name: off_shoulder
2018-05-10 10:59:04,436 - INFO - ProdClient - Model version: 1525854035
2018-05-10 10:59:04,443 - DEBUG - ProdClient - Establishing insecure channel took: 0.007186412811279297
2018-05-10 10:59:04,444 - DEBUG - ProdClient - Creating stub took: 4.410743713378906e-05
2018-05-10 10:59:04,444 - DEBUG - ProdClient - Creating request object took: 4.1961669921875e-05
2018-05-10 10:59:04,524 - DEBUG - ProdClient - Making tensor protos took: 0.07967543601989746
2018-05-10 10:59:04,573 - ERROR - ProdClient - <_Rendezvous of RPC that terminated with (StatusCode.UNAVAILABLE, OS Error)>
2018-05-10 10:59:04,574 - ERROR - ProdClient - Prediction failed!
2018-05-10 10:59:04,576 - INFO - __main__ - Prediction: {}

Any help! Urgent!

@stianlp
Copy link
Contributor

stianlp commented May 18, 2018

Can you show me the logs from the model server? StatusCode.UNAVAILABLE typically means that the server is not running, running on a different port, etc.

@PVanandgupta
Copy link

PVanandgupta commented May 18, 2020

facing similar issue, can you let me know if above was resolved?
how can i pass the image pixels, if i pass a list what data type needs to be used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants