This project is a web application for object detection built with Flask, utilizing Redis for caching and task queue management, Celery for asynchronous task processing, and Gunicorn as the WSGI HTTP server.
-
Clone the repository:
git clone https://github.com/yogesh1801/allos-assign.git cd allos-assign
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate
-
Install the dependencies:
pip install -r requirements.txt
-
To use your custom model on the flask application change the
MODEL_URL
inrun.sh
to link of your own model. (This application currently uses a lite version of Darknet framework trained on COCO 2017 dataset) -
The link to Redis server can also be changed by defining
CELERY_BROKER_URL
andCELERY_RESULT_BACKEND
inrun.sh
andworker.sh
shell script
-
Start the Redis server:
sudo systemctl start redis
-
Start the Celery worker:
bash worker.sh
-
Run the Flask application using Gunicorn:
bash run.sh
This repository contains code for using the SSD MobileNet V2 object detection model from TensorFlow Hub. The model is designed for efficient and high-speed object detection in images and video streams.
- Model Name: SSD MobileNet V2
- Version: 2
- Framework: TensorFlow
- Source: TensorFlow Hub
The SSD MobileNet V2 model combines the Single Shot Multibox Detector (SSD) framework with the MobileNet V2 backbone, optimized for mobile and embedded vision applications. It is pre-trained on the COCO dataset, which contains over 330,000 images and more than 80 object categories.
- SSD (Single Shot Multibox Detector): Enables detection of multiple objects within an image in a single pass.
- MobileNet V2: Lightweight and efficient, designed for fast inference on mobile and embedded devices.
- Pre-trained Weights: Trained on the COCO 2017 dataset, allowing recognition of common objects.
-
Create a EC2 instance using you amazon AWS console on a ubuntu image.
-
Clone the repository:
git clone https://github.com/yogesh1801/allos-assign.git cd allos-assign
-
Install and setup a redis server.
sudo apt install redis
-
Follow the instructions, same as setting up the project locally.
-
setup nginx
sudo apt install nginx
-
configure your nginx
vi /etc/nginx/sites-enabled/{your-app-name}
Go to insert mode and paste the following snippet
server { listen 80; location / { proxy_pass {address-to-your-gunicorn-server}; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
This project provides an API for object detection using the SSD MobileNet V2 model. The API supports uploading an image to detect objects and querying the status and result of the detection task.
- Endpoint:
/api/detect/
- Method:
POST
- Description: This endpoint accepts an image file, initiates an object detection task, and returns a task ID.
- Headers:
Content-Type: multipart/form-data
- Body:
file
: The image file to be uploaded for object detection.
- Status Code:
200 OK
- Body:
{ "task_id": "your-task-id" }
- Endpoint:
/task/{task_id}
- Method:
GET
- Description: This endpoint returns result of your task.
- Status Code:
200 OK
- Body:
{ "result": [ { "box" : [], "class" : "value", "name" : "class_name", "score" : "confidence_score", }, ], "status": "{status_of_request}" }
- The model is currently deployed at http://3.26.55.124/ and can be used to test the APIs.