tobegit3hub / simple_tensorflow_serving

Generic and easy-to-use serving service for machine learning models
https://stfs.readthedocs.io
Apache License 2.0
757 stars 192 forks source link

my model can be loaded but when I send request to do the predict I got some errors #90

Open Foina opened 3 years ago

Foina commented 3 years ago

The error I got: File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function return cors_after_request(app.make_response(f(*args, *kwargs))) File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise raise value File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functionsrule.endpoint File "/usr/local/lib/python3.8/site-packages/simple_tensorflow_serving/server.py", line 380, in decorated return f(decorator_args, decorator_kwargs) File "/usr/local/lib/python3.8/site-packages/simple_tensorflow_serving/server.py", line 180, in inference response = jsonify(json_result) File "/usr/local/lib/python3.8/site-packages/flask/json/init.py", line 370, in jsonify dumps(data, indent=indent, separators=separators) + "\n", File "/usr/local/lib/python3.8/site-packages/flask/json/init.py", line 211, in dumps rv = _json.dumps(obj, kwargs) File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/init.py", line 234, in dumps return cls( File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/usr/local/lib/python3.8/site-packages/flask/json/init.py", line 100, in default return _json.JSONEncoder.default(self, o) File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/encoder.py", line 179, in default raise TypeError(f'Object of type {o.class.name} ' TypeError: Object of type bytes is not JSON serializable

The request: { "model_name": "default", "model_version": 1, "data": { "inputs":["","",""] } }

I feel have difficulties to find the correct data structure, may I get some help from you?

tobegit3hub commented 3 years ago

It may be the issue of JSON serialization. Can you check the request data which might be string in correct format.

Foina commented 3 years ago

It may be the issue of JSON serialization. Can you check the request data which might be string in correct format.

Thank you for your reply. I have difficulties to figure out what should the requested data be