{"id":15679898,"url":"https://github.com/robmarkcole/yolov5-fastapi","last_synced_at":"2025-05-07T11:04:53.564Z","repository":{"id":52555491,"uuid":"361068713","full_name":"robmarkcole/yolov5-fastapi","owner":"robmarkcole","description":"FastAPI app exposing yolov5 object detection","archived":false,"fork":false,"pushed_at":"2022-07-05T04:21:40.000Z","size":7129,"stargazers_count":11,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-24T20:02:02.814Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robmarkcole.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"robmarkcole"}},"created_at":"2021-04-24T04:21:42.000Z","updated_at":"2024-11-12T17:12:40.000Z","dependencies_parsed_at":"2022-09-15T21:53:19.192Z","dependency_job_id":null,"html_url":"https://github.com/robmarkcole/yolov5-fastapi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robmarkcole%2Fyolov5-fastapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robmarkcole%2Fyolov5-fastapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robmarkcole%2Fyolov5-fastapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robmarkcole%2Fyolov5-fastapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robmarkcole","download_url":"https://codeload.github.com/robmarkcole/yolov5-fastapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231441303,"owners_count":18377281,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T16:38:58.075Z","updated_at":"2024-12-28T03:50:15.351Z","avatar_url":"https://github.com/robmarkcole.png","language":"Python","funding_links":["https://github.com/sponsors/robmarkcole"],"categories":[],"sub_categories":[],"readme":"# Yolov5 object detection with FastAPI\n\nCredit: originally a fork of [OurNemanja/YOLOv5-fastapi-celery-redis-rabbitm](https://github.com/OurNemanja/YOLOv5-fastapi-celery-redis-rabbitmq)\n\nApplication to expose Yolov5 model using FastAPI. Inferencing requests are submitted to a Celery task queue, and an asynchronous API is available for polling for results. This approach is described in detail in the excellent article [Serving ML Models in Production with FastAPI and Celery](https://towardsdatascience.com/deploying-ml-models-in-production-with-fastapi-and-celery-7063e539a5db) by [@jonathanreadshaw](https://github.com/jonathanreadshaw/ServingMLFastCelery)\n\n- [FastAPI](https://fastapi.tiangolo.com): python framework for building APIs\n- [Celery](https://celeryproject.org): task queue with focus on real-time processing\n- [RabbitMQ](https://www.rabbitmq.com): message broker used to route messages between API and the workers from Celery\n- [Redis](https://redis.io): in-memory database to store results and process status from the tasks\n\n\u003cimg src=img/schema.jpg\u003e\n\n# Usage\nRun all containers:\n\n```bash\ndocker-compose up\n```\n\nThis will start:\n- rabbitmq: message broker\n- redis: in-memory database on port 6379, simply used by rabbitmq\n- worker: application logic (Yolo model, FastAPI and Celery) on port 8000\n\nPerform some API requests using the integrated Swagger UI http://localhost:8000/docs\n\n\u003cimg src=img/doc.gif\u003e\n\nAPI Services available\n| Endpoint | Method | Description\n| --- | --- | --- |\n| http://localhost:8000/api/process | POST | Send one or more pictures to be processed by Yolov5. Return the task_id of each task.\n| http://localhost:8000/api/status/\u003ctask_id\u003e  | GET  | Retrieve the status of a given task\n| http://localhost:8000/api/result/\u003ctask_id\u003e    | GET  | Retrieve the results of a given task\n| http://localhost:8000/docs   | GET  | Documentation generated for each endpoint\n| http://localhost:15672   | GET  | RabbitMQ monitor. User: guest     Password: guest.\n| http://localhost   | GET  | Simple webapp to show how to use and display results from the API.\n\n## Development\n* `python3 -m venv venv`\n* `source venv/bin/activate`\n* `pip install -r requirements.txt`\n* `isort .`\n* `black .`\n* `pytest .` # none implemented\n\nOverview of the code\n- [api/app.py](api/app.py): expose the endpoints and send the request task to celery.\n- [celery_tasks/tasks.py](celery_tasks/tasks.py): receive the task and send (enqueue) to workers process.\n- [celery_tasks/yolo.py](celery_tasks/yolo.py): code to initialize and expose a method receive a picture and return the predictions.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobmarkcole%2Fyolov5-fastapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobmarkcole%2Fyolov5-fastapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobmarkcole%2Fyolov5-fastapi/lists"}