Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 54a389e

Browse files
authored
add service-streamer in bullets
1 parent 5094aac commit 54a389e

1 file changed

Lines changed: 6 additions & 15 deletions

File tree

intermediate_source/flask_rest_api_tutorial.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -326,21 +326,6 @@ def get_prediction(image_bytes):
326326
# Next steps
327327
# --------------
328328
#
329-
# Before putting the server into production, we need to solve two issues:
330-
#
331-
# - One request is served at a time, it is much slower compared to a local batch prediction
332-
# - It will cause CUDA out-of-memory error on GPU when there are large concurrent requests
333-
#
334-
# We can cache user requests in batches and schedule the prediction process.
335-
# Follow `service-streamer tutorial <https://github.com/ShannonAI/service-streamer/wiki/Vision-Recognition-Service-with-Flask-and-service-streamer>`_
336-
# you will solve these issues with a few lines of code.
337-
#
338-
# .. Note ::
339-
# `service-streamer <https://github.com/ShannonAI/service-streamer>`_ is a middleware for web service
340-
# of machine learning applications. Queued requests from users are sampled into mini-batches. Service-streamer
341-
# can significantly enhance the overall performance of the web server by improving GPU utilization.
342-
#
343-
#
344329
# The server we wrote is quite trivial and and may not do everything
345330
# you need for your production application. So, here are some things you
346331
# can do to make it better:
@@ -365,3 +350,9 @@ def get_prediction(image_bytes):
365350
# - You can also add a UI by creating a page with a form which takes the image and
366351
# displays the prediction. Check out the `demo <https://pytorch-imagenet.herokuapp.com/>`_
367352
# of a similar project and its `source code <https://github.com/avinassh/pytorch-flask-api-heroku>`_.
353+
#
354+
# - In this tutorial, we only showed how to build a service that could return predictions for
355+
# a single image at a time. We could modify our service to be able to return predictions for
356+
# multiple images at once. In addition, the `service-streamer <https://github.com/ShannonAI/service-streamer>`_
357+
# library automatically queues requests to your service and samples them into mini-batches
358+
# that can be fed into your model. You can check out `this tutorial <https://github.com/ShannonAI/service-streamer/wiki/Vision-Recognition-Service-with-Flask-and-service-streamer>`_.

0 commit comments

Comments
 (0)