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.
- 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
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
-
Navigate to the backend directory:
cd backend -
Create a Python virtual environment:
python -m venv venv -
Activate the virtual environment:
- Windows:
venv\Scripts\activate - Linux/Mac:
source venv/bin/activate
- Windows:
-
Install the required packages:
pip install -r requirements.txt -
Run the backend server:
uvicorn app:app --host 0.0.0.0 --port 8000 --reloadThe server will automatically download the U2Net model files on first use.
-
Verify the server is running by accessing
http://localhost:8000/health/in your browser.
-
Make sure Flutter is installed. If not, follow the official Flutter installation guide.
-
Install dependencies:
flutter pub get -
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
- For Android emulator: Use
-
Run the Flutter app:
flutter run
- Launch the app after setting up both backend and frontend.
- Tap on "Gallery" to select an image from your photo library or "Camera" to take a new photo.
- After selecting an image, tap "Remove Background" to process the image.
- Once processing is complete, the transparent image will be displayed.
- Tap "Save" to save the image to your device gallery.
- Tap "New Image" to process another image.
- Backend: Python, FastAPI, PyTorch, U2Net model
- Frontend: Flutter, Dart
- Image Processing: OpenCV, PIL
MIT License