I’m looking for a straightforward way to serve a TensorFlow model through a REST API, possibly using a framework like Flask. Despite searching through various repositories, I haven’t come across a clear example that fits my needs.
I’m intentionally avoiding TensorFlow Serving because, although it suits large-scale Google applications, its reliance on gRPC, Bazel, C++ coding, and protobuf makes it unnecessarily complex for simpler tasks. I would appreciate guidance on how to implement a lightweight, RESTful solution for deploying my model.
I recently tackled a similar challenge by deploying a TensorFlow model with Flask rather than relying on TensorFlow Serving. I loaded the model using TensorFlow’s load_model function and set up a Flask endpoint to handle incoming JSON requests. The data is first parsed and pre-processed to match the model input format, after which the model makes predictions that are returned as JSON responses. This method simplifies the deployment process and offers great flexibility, though careful consideration for concurrency and error handling is necessary when scaling.
hey, i built a simple flask api by loading the model and then calling model.predict on json data. added some rudimantary error checks for bad inputs. its not perfect but works fine for testing and small loads, so hope that helps!