Skip to main content

A FastAPI backend for image recognition

Project description

Image-Recognition-App

This app is an example of a pure MLOps probelm solving. The purpose of the app is to input an image and via a MobileNet predict the objects in it. Originally it consisted on two separate components:

  • A standalone Python package with the OpenCV model.
  • A server side API developed with FastAPI that consumes de model package, deployed in Vercel
  • A dummy client side developed with HTML, CSS and Javascript deployed in GitHub Pages.

However, Vercel supports until 250MB of app size, and the model package, which uses OpenCV and another ML libraries, exceeded that number. Then, another solution had to be found. The model package was transformed into another API developed in Gradio and hosted in the free service Hugging Face. Then, the first API now consumes from this second API. Moreover, the image sending handling had to be changed, consisting in several transformations between lists, JSON strings and byte objects.

The resulting architecture is as follows:

  1. A dummy client side developed with HTML, CSS and Javascript deployed in GitHub Pages that calls API_1.
  2. An API_1 developed with FastAPI hosted in Vercel that calls API_2.
  3. An API_2 that hosts the model, developed with Gradio and hosted in Hugging Face.
  4. A Python package with the model, unused and replaced by API_2 because of hardware limitations.

API_1 supports automated CI/CD in GitHub Actions. Building includes installing of dependencies, testing in Pytest, formatting with black and linter. Deployment includes both GitHub Pages and Vercel.

The model Python package supports automated CI/CD in GitHub Actions. Building inludes installing of dependencies, testing in Pytest, formatting with black and linter and package building with setuptools. Deployment includes publishing to PyPI with Twine.

FULL TECHNOLOGIES STACK

[API]

  • FastAPI
  • Uvicorn
  • Gradio

[Machine Learning]

  • Numpy
  • matplotlib
  • Pillow
  • OpenCV

[Services]

  • GitHub Actions
  • Vercel
  • Hugging Face
  • PyPI

[Testing, formatting and building]

  • Pytest
  • Flake8
  • Black
  • Pre-commit
  • setuptools
  • Twine

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gamr_backend_api_service-1.0.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gamr_backend_api_service-1.0.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file gamr_backend_api_service-1.0.0.tar.gz.

File metadata

File hashes

Hashes for gamr_backend_api_service-1.0.0.tar.gz
Algorithm Hash digest
SHA256 41300683fa567fb4063ddc21c848e9d0350e146a0b09953fd6c78b88d8e1a23a
MD5 c4e2b3cbad81ebd5b59ce6c24cd2ffdd
BLAKE2b-256 e787f1aa314d5c2affe33a8381127ab764c6d63c346bc75d0e000a670c80e6b0

See more details on using hashes here.

File details

Details for the file gamr_backend_api_service-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gamr_backend_api_service-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7280d31e233c83c5d369d98f994ea4015d642c174a68a86aff9369d349ccd383
MD5 b3ce1709ae355d218e499f8cc31516f6
BLAKE2b-256 57d721f48360dfb077369c0f62a5d238826b0f4c1bf3cb8c5a6dc59fa78913ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page