Skip to content

Repository files navigation

Background Remover Application

A full-stack application for removing backgrounds from images using U2Net deep learning model. This project implements a Flutter frontend with a FastAPI backend that uses the U2Net model for high-quality background removal without relying on paid APIs.

Features

  • Upload images from gallery or camera
  • Remove backgrounds using advanced U2Net deep learning model
  • Download processed transparent images
  • Cross-platform support via Flutter frontend
  • Completely free and self-hosted solution

Project Structure

background_remover_app/
│
├── backend/
│   ├── app.py                 # FastAPI server
│   ├── u2net/                 # Deep learning model files
│   │   └── model.py           # U2NET model implementation
│   ├── utils/
│   │   ├── remove_bg.py       # Background removal function
│   │   └── download_model.py  # Model download utility
│   └── requirements.txt       # Python dependencies
│
├── lib/
│   ├── screens/
│   │   └── home_screen.dart   # Main app screen
│   ├── widgets/
│   │   └── loading_indicator.dart # Loading UI component
│   ├── services/
│   │   └── api_service.dart   # Backend API communication
│   └── main.dart             # Flutter app entry point
│
└── assets/
    └── images/               # App images and resources

Setup Instructions

Backend Setup

  1. Navigate to the backend directory:

    cd backend
    
  2. Create a Python virtual environment:

    python -m venv venv
    
  3. Activate the virtual environment:

    • Windows: venv\Scripts\activate
    • Linux/Mac: source venv/bin/activate
  4. Install the required packages:

    pip install -r requirements.txt
    
  5. Run the backend server:

    uvicorn app:app --host 0.0.0.0 --port 8000 --reload
    

    The server will automatically download the U2Net model files on first use.

  6. Verify the server is running by accessing http://localhost:8000/health/ in your browser.

Frontend Setup

  1. Make sure Flutter is installed. If not, follow the official Flutter installation guide.

  2. Install dependencies:

    flutter pub get
    
  3. Update API URL:

    • For Android emulator: Use http://10.0.2.2:8000 (default)
    • For physical devices or iOS simulator: Use your computer's IP address like http://192.168.1.X:8000
    • Edit the baseUrl in lib/services/api_service.dart
  4. Run the Flutter app:

    flutter run
    

Usage Guide

  1. Launch the app after setting up both backend and frontend.
  2. Tap on "Gallery" to select an image from your photo library or "Camera" to take a new photo.
  3. After selecting an image, tap "Remove Background" to process the image.
  4. Once processing is complete, the transparent image will be displayed.
  5. Tap "Save" to save the image to your device gallery.
  6. Tap "New Image" to process another image.

Technologies Used

  • Backend: Python, FastAPI, PyTorch, U2Net model
  • Frontend: Flutter, Dart
  • Image Processing: OpenCV, PIL

License

MIT License

Acknowledgements

  • U2Net - Original implementation of the U2Net model
  • FastAPI - For the high-performance API framework
  • Flutter - For the cross-platform UI framework

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages