rebrot is a Python application designed to perform image inpainting on photographs using advanced artificial intelligence and image processing models. This project was developed at the Polytechnic University of Valencia (UPV) as part of the Salvem Les Fotos initiative.
It uses the following technologies:
- 🔍 YoloV8 for automatic detection of stained or damaged regions.
- 🔬 SAM2 (Segment Anything Model v2) for stain segmentation. (Alternative 1)
- 🧠 UNet for precise segmentation of affected regions. (Alternative 2)
- 🤖 SegFormer for precise segmentation of affected regions. (Alternative 3)
- 👤 LangSAM for face detection.
- 🎨 Stable Diffusion Inpainting XL for image restoration.
- 🏞️ OpenCV for image processing.
- 🌐 Gradio for building an accessible web interface.
- 🐍 Python >= 3.10
- 🚀 CUDA-compatible GPU (optional, but recommended for better performance)
For now, the Yolo, UNet, and Segformer models are not publicly available. They will be soon.
git clone https://github.com/jd-galvan/rebrot.git
cd rebrotpython -m venv venv
source venv/bin/activate # On Linux/macOS
venv\Scripts\activate # On Windowspip install -r requirements.txtThis project requires certain environment variables to function properly. An example file .env-example is provided as a reference.
-
Copy the
.env-examplefile and rename it to.env:cp .env-example .env
-
Edit the
.envfile and fill in the following values:CUDA_DEVICE=cuda:0 # You can set it to "cuda:0", "cuda:1", or whichever GPU you wish to use. HUGGINGFACE_HUB_TOKEN=your_token_here APP_USER=your_app_username APP_PASSWORD=your_app_password
To run the application, simply execute the following command:
python main_yolo.pyThis will launch a Gradio web interface where you can upload and process images to remove stains.
Contributions are welcome! If you'd like to improve the project, please:
- Fork the repository.
- Create a new branch (
git checkout -b my-new-feature). - Make your changes and commit them.
- Submit a pull request.
This project is licensed under the MIT License. For more details, see the LICENSE file. 🚀
