Skip to content

This project leverages the Segformer pretrained model to perform billboard segmentation through semantic segmentation, specifically targeting Indian billboards. By applying transfer learning on a custom dataset, the model accurately classifies and delineates billboards within images, enabling efficient detection and analysis.

License

Notifications You must be signed in to change notification settings

Deepchavda007/Billboard-Segmentation-using-Segformer

Repository files navigation


Billboard Segmentation

The Uncompromising Code Formatter Python Versions CV-OpenCV-red TensorFlow Segformer License: MIT

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.

Overview

This project is split into two key sections:

  1. Training: We fine-tune the Segformer model on a custom Indian billboard dataset using semantic segmentation techniques.
  2. 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.

Step 1: Clone the Repository

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

Step 2: Create a Virtual Environment

Creating a virtual environment is crucial to manage dependencies.

For Mac & Linux:

Run the following commands:

python3 -m venv env/segmentation
source env/segmentation/bin/activate

For Windows:

Run these commands in your Command Prompt or PowerShell:

python -m venv env\segmentation
.\env\segmentation\Scripts\activate

Step 3: Install dependencies

With your virtual environment active, install the required Python packages:

For Windows:

pip install -r requirements.txt

For Mac & Linux:

pip3 install -r requirements.txt

Step 4: Run the Flask API

Run the Flask API using the following command:

python3 app.py

API Endpoints:

  • The application provides the following endpoints:

/transform_image

  • 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
      }

Training

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.

Contribution

About

This project leverages the Segformer pretrained model to perform billboard segmentation through semantic segmentation, specifically targeting Indian billboards. By applying transfer learning on a custom dataset, the model accurately classifies and delineates billboards within images, enabling efficient detection and analysis.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published