Files
FOBG/docs/README.md
2026-05-16 00:15:37 +03:00

92 lines
2.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 🪄 FOBG — AI Background Remover
Remove backgrounds from **images** and **videos** using AI, powered by [rembg](https://github.com/danielzhanika/rembg).
## Features
- **Image BG Removal** — Upload any image, get a transparent PNG
- **Video BG Removal** — Frame-by-frame processing with alpha channel
- **Multiple AI Models** — u2net, u2netp, u2net_human_seg, isnet-general-use, isnet-anime
- **Gradio UI** — Clean, interactive web interface
- **CLI Mode** — Script-friendly command-line interface
- **Fine-tune Controls** — Alpha matting, thresholds, erosion mask
## Quick Start
### 1. Install Dependencies
```bash
cd /mnt/games/Coding/Python/AI/FOBG
source .venv/bin/activate
pip install -r requirements.txt
```
### 2. Launch the Web UI
```bash
python main.py
```
Opens at [http://localhost:7860](http://localhost:7860)
### 3. CLI Mode
```bash
python main.py --cli input.jpg # Image
python main.py --cli video.mp4 --video # Video
```
## Project Structure
```
FOBG/
├── main.py # Entry point (Gradio + CLI)
├── requirements.txt # Dependencies
├── src/
│ ├── core/
│ │ ├── bg_remove.py # Image BG removal (rembg)
│ │ └── video_bg_remove.py # Video BG removal (OpenCV + rembg)
│ └── ui/
│ └── app.py # Gradio web interface
├── output/ # Processed results saved here
├── tests/ # Unit tests
└── docs/
└── README.md # This file
```
## Available Models
| Model | Description | Speed |
|-------|-------------|-------|
| `u2net` | Default, balanced quality/speed | ⚡ Fast |
| `u2netp` | Lightweight, slightly lower quality | 🚀 Fastest |
| `u2net_human_seg` | Optimized for human segmentation | ⚡ Fast |
| `u2net_3b` | Heavy, higher accuracy | 🐢 Slower |
| `isnet-general-use` | General purpose, high accuracy | 🐢 Slower |
| `isnet-anime` | Optimized for anime illustrations | ⚡ Fast |
## Controls
### Image Tab
- **Upload Image** — PNG, JPEG, or WebP
- **Model** — Choose the AI model
- **Alpha Matting** — Fine-tune edges (slower but cleaner)
- **Foreground Threshold** — How much is considered foreground (1-255)
- **Background Threshold** — How much is considered background (1-255)
- **Erosion Mask Dilation** — Morphological operation on the mask (0-32)
### Video Tab
- **Upload Video** — MP4, AVI, WebM, or MOV
- **Model** — Same models as image tab
- **Alpha Matting** — Fine edge detection per frame
- **Erosion Mask Dilation** — Morphological operation on the mask
## Notes
- Image processing: 15 seconds per image
- Video processing: frame-by-frame, can take minutes for longer clips
- All outputs saved to `output/` directory
- First run downloads the AI model (~170 MB for u2net)