-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
java.lang.RuntimeException: Unexpected code Response{protocol=http/1.1, code=400, message=Bad Request, url=http://localhost:8501/v1/models/myfruit:predict} #2215
Comments
@x13872140520, The error indicates that the Java client code for sending REST request to TF Serving API is sending a bad request. Please make sure you are making request in correct format. Here is a python example for making REST request to your model in TF Serving. Thank you! |
This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you. |
@singhniraj08 Thanks for the answer, this problem is solved, the problem is that the code training the model needs to add base64 related processing, as follow: and then it can return the result of probability distribution as follow: |
@x13872140520, The probability distribution issue would be caused by some issue in model or when interpreting predictions from client side. Please make sure the model predictions are working correctly. And since there are no issues pending from Tensorflow Serving side, requesting you to close this issue. Thank you! |
This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you. |
System information
operating system:
win11 64bit
tensorflow/serving version:
2.14.1
TFserving Deployment mode:
RESTful API
python requirements.txt:
tensorflow-cpu == 2.3.0 pyqt5 pillow opencv-python matplotlib
Describe the problem
Hello everyone, my demand is to build an interface with java, the front-end transmits an arbitrary image, java uses
tensorflow for java
ortensorflow serving
to use the model to make predictions, java gets the prediction results and returns to the front-end.Now I am ready to experiment with python to train the model, save the model as saved_model, and then set up tensorflow serving. Now the local docker container has been successfully started.
The python code for model training is copied online, and the specific code is as follows:
The model training is also trained, and it is predictable in the python version using the h5 format. The model information is as follows:
java as the client request code:
java is having trouble making requests to
tensorflow serving
and is not sure what to do. The error is as follows:java.lang.RuntimeException: Unexpected code Response{protocol=http/1.1, code=400, message=Bad Request, url=http://localhost:8501/v1/models/myfruit:predict}
Look at https://tensorflow.google.cn/tfx/serving/api_rest#classify_and_regress_api here document as is can use base64 as parameters.
I tried the following formats, all failed, all reported similar to 400 errors
I am a java novice, tensorflow is also a novice, a lot of operations, basic terminology is not clear, do not know what knowledge is missing. Thank you for your generous advice. Do the parameters in sensory model training have a strong relationship with tfserving entry here? How do I organize parameters?
The text was updated successfully, but these errors were encountered: