https://github.com/poorya96/object-removal-using-opencv---stable-diffusion
Object Removal Using OpenCV & Stable Diffusion
https://github.com/poorya96/object-removal-using-opencv---stable-diffusion
object-removal opencv python stable-diffusion
Last synced: 3 months ago
JSON representation
Object Removal Using OpenCV & Stable Diffusion
- Host: GitHub
- URL: https://github.com/poorya96/object-removal-using-opencv---stable-diffusion
- Owner: poorya96
- License: mit
- Created: 2025-02-13T13:24:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-13T13:56:30.000Z (over 1 year ago)
- Last Synced: 2025-02-13T14:30:36.607Z (over 1 year ago)
- Topics: object-removal, opencv, python, stable-diffusion
- Language: Python
- Homepage:
- Size: 9.66 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Object Removal Using OpenCV & Stable Diffusion
## Overview
This project explores different methods for object removal from images using both traditional computer vision techniques and deep learning-based inpainting. The methods evaluated include:
- **OpenCV Inpainting (INPAINT_NS & INPAINT_TELEA)**: Traditional image inpainting algorithms.
- **Auto-Masking with OpenCV**: Automatically generating a mask for object removal.
- **Stable Diffusion Inpainting**: A deep learning-based method for realistic object removal.
## Methods & Comparison
Each method has been tested and evaluated based on accuracy, speed, and computational requirements:
| Method | Accuracy | Speed | Computational Cost | Suitability |
|-----------------------------|----------|--------|---------------------|-------------|
| **INPAINT_NS (OpenCV)** | Low | Fast | Low | Minor object removal |
| **INPAINT_TELEA (OpenCV)** | Low | Fast | Low | Small defect correction |
| **Auto Masking + OpenCV** | Very Low | Medium | Low | Poor due to inaccurate mask |
| **Stable Diffusion Inpainting** | High | Slow | High (GPU required) | Best for complex removals |
## Installation
To run this project, make sure you have the required dependencies installed.
### **1. Clone the Repository**
```bash
git clone https://github.com/yourusername/object-removal.git
cd object-removal
```
### **2. Create a Virtual Environment (Optional but Recommended)**
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
### **3. Install Dependencies**
```bash
pip install -r requirements.txt
```
## Example Results
### **Original Image**

### **INPAINT_NS Result**

### **INPAINT_TELEA Result**

### **Stable Diffusion Inpainting Result**

## Conclusion
- **OpenCV-based methods** are fast but struggle with large missing areas.
- **Stable Diffusion** provides superior results but is computationally expensive.
## References
- OpenCV Documentation: [https://docs.opencv.org/](https://docs.opencv.org/)
- Stable Diffusion Inpainting: [https://huggingface.co/stabilityai](https://huggingface.co/stabilityai)
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.