Use Segformer pretrained model to perform billboard segmentation through semantic segmentation. It specifically targets Indian billboards, and the model precisely delineates billboards within images, allowing for efficient detection and analysis.
This project is split into two key sections:
- Training: We fine-tune the Segformer model on a custom Indian billboard dataset using semantic segmentation techniques.
- API for Billboard Replacement: Once the billboards are segmented, the API provides a method to replace billboards using a perspective transformation approach to accurately fit new content onto existing billboards.
For details on training the model, follow the dedicated Training README and explore the Google Colab Notebook for downstream tasks.
First, clone the repository to your local machine using Git. Open your terminal and run:
git clone https://github.com/Deepchavda007/Billboard-Segmentation-using-Segformer.git
Creating a virtual environment is crucial to manage dependencies.
Run the following commands:
python3 -m venv env/segmentation
source env/segmentation/bin/activate
Run these commands in your Command Prompt or PowerShell:
python -m venv env\segmentation
.\env\segmentation\Scripts\activate
With your virtual environment active, install the required Python packages:
pip install -r requirements.txt
pip3 install -r requirements.txt
Run the Flask API using the following command:
python3 app.py
- The application provides the following endpoints:
- Method: POST
- Description: This endpoint removes the background from a billboard and replaces it with the provided image, using perspective transformation to adjust the replacement image to fit the billboard's orientation and perspective.
- Request Body:
{ "original_image_url": "https://example.com/original.png", "replacement_image_url": "https://example.com/replacement.png" }
- Response:
- Success:
{ "data": { "url": "https://s3.amazonaws.com/bucketname/path/to/transformed_image.png" }, "message": "Image processed and transformed successfully", "status": true }
- Success:
BillboardAI.mp4
For those interested in training or fine-tuning the Segformer model, follow the dedicated training instructions in the Training README or use the provided Google Colab Notebook for downstream tasks such as segmentation and billboard replacement.