Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Building Data Science Applications with FastAPI - Second Edition

You're reading from  Building Data Science Applications with FastAPI - Second Edition

Product type Book
Published in Jul 2023
Publisher Packt
ISBN-13 9781837632749
Pages 422 pages
Edition 2nd Edition
Languages
Author (1):
François Voron François Voron
Profile icon François Voron

Table of Contents (21) Chapters

Preface Part 1: Introduction to Python and FastAPI
Chapter 1: Python Development Environment Setup Chapter 2: Python Programming Specificities Chapter 3: Developing a RESTful API with FastAPI Chapter 4: Managing Pydantic Data Models in FastAPI Chapter 5: Dependency Injection in FastAPI Part 2: Building and Deploying a Complete Web Backend with FastAPI
Chapter 6: Databases and Asynchronous ORMs Chapter 7: Managing Authentication and Security in FastAPI Chapter 8: Defining WebSockets for Two-Way Interactive Communication in FastAPI Chapter 9: Testing an API Asynchronously with pytest and HTTPX Chapter 10: Deploying a FastAPI Project Part 3: Building Resilient and Distributed Data Science Systems with FastAPI
Chapter 11: Introduction to Data Science in Python Chapter 12: Creating an Efficient Prediction API Endpoint with FastAPI Chapter 13: Implementing a Real-Time Object Detection System Using WebSockets with FastAPI Chapter 14: Creating a Distributed Text-to-Image AI System Using the Stable Diffusion Model Chapter 15: Monitoring the Health and Performance of a Data Science System Index Other Books You May Enjoy

Implementing a WebSocket to perform object detection on a stream of images

One of the main benefits of WebSockets, as we saw in Chapter 8, Defining WebSockets for Two-Way Interactive Communication in FastAPI, is that it opens a full-duplex communication channel between the client and the server. Once the connection is established, messages can be passed quickly without having to go through all the steps of the HTTP protocol. Therefore, it’s much more suited to sending a lot of data in real time.

The point here will be to implement a WebSocket endpoint that is able to both accept image data and run object detection on it. The main challenge here will be to handle a phenomenon known as backpressure. Put simply, we’ll receive more images from the browser than the server is able to handle because of the time needed to run the detection algorithm. Thus, we’ll have to work with a queue (or buffer) of limited size and drop some images along the way to handle the stream...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}