Skip to content

foooooooooooooooooooooooooootw/DeepMosaicsPlus

 
 

Repository files navigation


DeepMosaicsPlus

AI-powered mosaic removal for images and videos

Python 3.6+ PyTorch Platform


✨ What's New in Plus

This is an optimized fork of the original DeepMosaics project with significant performance improvements:

  • 🚀 6x faster processing - Optimized GPU utilization (1h → 10 mins on AMD 7800XT)
  • 🎮 AMD GPU support - DirectML integration for AMD graphics cards
  • Hardware acceleration - DirectX 11 for AMD, CUDA for NVIDIA
  • 🔧 Auto-detection - Automatically detects and uses available GPU
  • 🐛 Bug fixes planned - Auto dependency instllation, async I/O, batch processing

Note: The original project was revolutionary for the time - a proof of concept of sorts - and as such does not use CPU/GPU resources efficiently. This fork addresses that with substantial performance gains. Most programs also only use CUDA which locks all AMD GPU users out. Only the mosaic removal part was optimized, adding mosaics was not touched by me.


🎯 Features

  • Image & Video Processing - Remove mosaics from both static images and video files
  • Multiple Network Architectures - UNet, ResNet, HD models for different use cases
  • Flexible Detection - Adjustable sensitivity for mosaic detection
  • Traditional Fallback - Non-AI method available for edge cases
  • GUI & CLI - Choose between graphical interface or command-line operation
  • Customizable Output - Control resolution, FPS, and processing parameters

🖼️ Results

Demo

Comparison with DeepCreamPy

Mosaic Image DeepCreamPy DeepMosaicsPlus
image image image
image image image

🚀 Quick Start

Option 1: GUI (Easiest)

Double-click deepmosaicplusui.py or run:

python deepmosaicplusui.py

Option 2: Command Line

python deepmosaic.py --media_path "weenus.mkv" --model_path "clean_youknow_video.pth"

📋 Requirements

System Requirements

  • OS: Windows (DirectML requirement)
  • Python: 3.6 or higher
  • GPU: Any AMD or NVIDIA GPU (CPU fallback available)

Dependencies

Core Libraries

GPU Support

  • AMD GPUs: torch_directml (auto-detects DirectML devices)
  • NVIDIA GPUs: CUDA toolkit

GUI (Optional)

  • customtkinter

⚙️ Installation

Option A: Download Release (Easiest)

Download the latest pre-packaged release with models included:

📦 Download DeepMosaicsPlus.zip

Extract the zip file and you're ready to go! Skip to the Usage section.

Option B: Clone from Source

1. Clone the Repository

git clone https://github.com/foooooooooooooooooooooooooootw/DeepMosaicsPlus.git
cd DeepMosaicsPlus

2. Install Dependencies

pip install torch torchvision opencv-python customtkinter

For AMD GPUs:

pip install torch-directml

For NVIDIA GPUs: Install CUDA toolkit from NVIDIA's website

3. Download Pre-trained Models

Download models and place them in ./pretrained_models/

Required files: Place mosaic_position.pth and clean_youknow_video.pth in the same directory as deepmosaic.py


🎮 Usage

Basic Command

python deepmosaic.py --media_path "input.mp4" --model_path "clean_youknow_video.pth"

Process Specific Time Range

python deepmosaic.py --media_path "video.mp4" \
                      --start_time "00:01:30" \
                      --last_time "00:05:00" \
                      --model_path "clean_youknow_video.pth"

Adjust Detection Sensitivity

python deepmosaic.py --media_path "image.jpg" \
                      --mask_threshold 30 \
                      --model_path "clean_youknow_video.pth"

Lower threshold = more sensitive detection


📖 Command-Line Arguments

Essential Arguments

Argument Type Default Description
--media_path str './imgs/ruoruo.jpg' Path to input image or video
--model_path str './clean_youknow_video.pth' Path to the pretrained model
--result_dir str './result' Output directory
--gpu_id str '0' GPU ID (auto-detected with DirectML)

Video Processing

Argument Type Default Description
-ss, --start_time str '00:00:00' Start time (HH:MM:SS)
-t, --last_time str '00:00:00' Duration (00:00:00 = entire video)
--fps int 0 Output FPS (0 = keep original)

Detection & Processing

Argument Type Default Description
--mask_threshold int 48 Mosaic detection sensitivity (0-255, lower = more)
--netG str 'auto' Network: unet_128, unet_256, resnet_9blocks, HD, video
--mosaic_position_model_path str 'auto' Model for detecting mosaic positions
--all_mosaic_area flag True Find all mosaic regions (not just largest)
--no_feather flag False Disable edge feathering (faster, lower quality)

Advanced Options

Argument Type Default Description
--traditional flag False Use non-AI traditional method
--no_preview flag False Disable preview window (for servers)
--output_size int 0 Output resolution (0 = original)
--temp_dir str './tmp' Temporary files directory
--debug flag False Enable debug mode

For complete documentation, see [options_introduction.md]


🔧 Technical Details

GPU Acceleration

DirectML (AMD GPUs)

  • Automatically detects DirectML-capable devices
  • Hardcoded to use GPU with CPU fallback
  • Uses DirectX 11 for hardware video acceleration
  • No need for --gpu_id argument

CUDA (NVIDIA GPUs)

  • Uses CUDA for hardware acceleration
  • Specify GPU with --gpu_id (e.g., --gpu_id 0 by default)

Performance Optimization

This fork improves on the original by:

  • Better GPU utilization (original barely used GPU resources)
  • Optimized FFmpeg arguments for hardware acceleration
  • DirectML integration for broader GPU support

🏗️ Training Your Own Models

Want to train on custom datasets? Check out the training guide.


📝 Roadmap

  • Auto detect dependencies and install if missing
  • Add batch processing for multiple files
  • GPU workload saturation improvements

🙏 Acknowledgements

This project builds upon excellent work from:

Special thanks to the original DeepMosaics project. This fork exists to optimize performance and add AMD GPU support. 🚀


💬 Support

Found a bug or have a feature request? Open an issue


If this project helped you, consider giving it a ⭐!

About

Automatically remove the mosaics in images and videos with any GPU. Offers DirectML for AMD instead of only CUDA like most other programs.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Python 98.0%
  • C++ 1.2%
  • CMake 0.8%