Remove unwanted objects from photos with AI - No coding required!
DeepRazor makes professional photo editing accessible to everyone. Simply upload your image, mark what you want to remove, and let our AI seamlessly fill in the background. Perfect for social media, real estate, e-commerce, or just cleaning up your personal photos.
- π¨ Remove Any Object: People, cars, text, unwanted items - anything!
- ποΈ Smart Background Fill: AI automatically reconstructs what was behind the object
- π Multiple Ways to Select: Draw masks manually or let AI detect objects automatically
- π» Web Interface: No coding needed - just point, click, and download
- β‘ Fast Results: Get professional results in seconds
# 1. Clone and install
git clone https://github.com/ShubhamKNIT/DeepRazor.git
cd DeepRazor
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# Only for Linux/Ubuntu
sudo apt-get update
sudo apt-get install freeglut3-dev libgtk2.0-dev
# 2. Launch the app
cd Deployment
streamlit run app.py
# 3. Open http://localhost:8501 in your browser and start editing!| Tool | What It Does | Best For |
|---|---|---|
| π How to Use | Interactive tutorial with demo video | First-time users |
| βοΈ Draw Mask | Manually draw what to remove | Precise selection, complex shapes |
| π― YOLO Detection | AI detects mask of 80+ object types automatically | Common objects (people, cars, animals) |
| π¨ Inpaint Anything | Upload image + mask for instant results | Quick masked object removal |
- Input: JPG, JPEG, PNG images
- Output: High-quality PNG images
- Mask: PNG images (black = keep, white = remove)
from inpaint_anything_predicts import make_inference
# Basic usage
image_bytes = open("photo.jpg", "rb").read()
mask_bytes = open("mask.png", "rb").read()
result = make_inference(image_bytes, mask_bytes, "onnx_gen_models/ia_gen_39.onnx")
# Save result
with open("result.png", "wb") as f:
f.write(result)DeepRazor/
βββ Deployment/ # π Web Application
β βββ app.py # Main Streamlit app
β βββ how_to_use.py # Tutorial page
β βββ draw_mask.py # Manual mask drawing
β βββ segment_anything.py # YOLO object detection
β βββ inpaint_anything.py # Core inpainting interface
β βββ onnx_gen_models/ # Pre-trained models
β βββ ia_gen_10.onnx ... ia_gen_59.onnx
β βββ run_onnx.py # ONNX inference
βββ InpaintingModule/ # π¬ Research & Training
β βββ train.py # Training entry point
β βββ test.py # Testing entry point
β βββ validate.py # Validation entry point
β βββ src/dataset/ # Dataset preparation scripts
β βββ src/model/ # Model architectures
β βββ src/utils/ # Training utilities
β βββ Logs and Results # Training Logs and Results
βββ requirements.txt # Dependencies
DeepRazor implements a two-stage Generative Adversarial Network using Contextual Residual Aggregation (CRA):
Input Image + Mask
β
Coarse Generator (256Γ256) β Coarse Inpainting
β
Refinement Generator (512Γ512) β Final Result
β
Discriminator β Quality Assessment
- Coarse Generator: Fast 256Γ256 initial inpainting with gated convolutions
- Refinement Generator: High-quality 512Γ512 enhancement with contextual attention
- Progressive Training: Coarse stage first, then joint refinement training
- Gated Convolutions: Dynamic feature selection based on mask validity
- Contextual Attention Module (CAM): Transfers context from valid to masked regions
- Multi-Scale Dilated Blocks: Capture context at rates [1, 2, 4, 8, 16]
- Swin Transformer Integration: Global context modeling in final training epochs (experimental)
# Coarse Stage
L_coarse = Ξ»_L1 * L1_loss + Ξ»_FFT * Fourier_loss + Ξ»_TV * TV_loss
# Refinement Stage
L_refine = Ξ»_L1 * L1_loss + Ξ»_FFT * Fourier_loss + Ξ»_adv * Adversarial_loss +
Ξ»_perceptual * VGG_loss + Ξ»_FM * Feature_matching_loss
# Discriminator
L_disc = Hinge_loss + Gradient_penalty- Source: Real-world Object Removal Dataset
- Size: 236GB original β 41.5GB prepared subset
- Training: ~24K high-quality triplets [Image, Mask, Ground Truth]
- Validation: ~4K instances for evaluation
- Resolution: 512Γ512 for training, supports higher resolutions
Detailed explanation of all core modules, functions, and architectural breakdown.
π Read the full Module Documentation (PDF)
# 1. Prepare dataset
cd RORD-dataset-preparation
python prepare_dataset.py # Follow dataset preparation guide
# 2. Configure training
cd InpaintingModule
vim env_var.py # Set dataset paths and hyperparameters
# 3. Start training
python train.py --start_epoch 1 --num_epochs 50 --batch_size 16 --device cuda- Modular Design: Easily extend or replace components
- Mixed Precision Training: 50% memory reduction with AMP
- Resume Training: Automatic checkpoint loading
- Real-time Monitoring: Live loss tracking and GPU usage
- Validation Metrics: PSNR, SSIM, FID, LPIPS evaluation
- Result Visualization: Sample outputs saved during training
cd Deployment/onnx_gen_models
python export_to_onnx.py --chkpt_no 50 --model_path ../../InpaintingModule/checkpoints/| Metric | Value | Description |
|---|---|---|
| PSNR | 21.5+ dB | Peak Signal-to-Noise Ratio |
| SSIM | 0.86+ | Structural Similarity Index |
| FID | 20-28 | FrΓ©chet Inception Distance |
| LPIPS | 0.25-0.26 | Learned Perceptual Image Patch Similarity |
- Image Inpainting: Core inpainting research and benchmarking
- Object Removal: Real-world object removal in natural images
- Context Understanding: Studying contextual attention mechanisms
- GAN Training: Advanced adversarial training techniques
- Loss Function Design: Multi-objective optimization in computer vision
- π Bug Reports: Found an issue? Create a detailed bug report
- π‘ Feature Requests: Suggest new functionality or improvements
- π§ Code Contributions: Submit pull requests for bug fixes or features
- π Documentation: Improve tutorials, examples, or API docs
- π Research: Share new architectures, loss functions, or training techniques
# 1. Fork and clone
git fork https://github.com/ShubhamKNIT/DeepRazor.git
git clone https://github.com/YourUsername/DeepRazor.git
cd DeepRazor
# 2. Create feature branch
git checkout -b feature/amazing-improvement
# 3. Make changes and test
pip install -r requirements.txt
# Test your changes thoroughly
# 4. Submit pull request
git commit -am "Add amazing improvement"
git push origin feature/amazing-improvement
# Create PR on GitHub-
Sagong, M.-C., et al. (2022)
RORD: A Real-world Object Removal Dataset
BMVC 2022 - Paper -
Yi, Z., et al. (2020)
Contextual Residual Aggregation for Ultra High-Resolution Image Inpainting
arXiv:2005.09704 - Paper -
Yu, J., et al. (2019)
Free-form Image Inpainting with Gated Convolution
ICCV 2019 - Paper
- RORD Dataset creators for high-quality training data
- Ultralytics YOLO team for object detection capabilities
- Streamlit community for the amazing web framework
- PyTorch and ONNX teams for ML infrastructure
- FastSAM contributors for rapid segmentation
- Open Source Community for inspiration and support
π¨ Turn any photo into a masterpiece - Try DeepRazor today!
Made with β€οΈ by Shubham Kumar | Star β if you find this useful!