Skip to content

Z863058/demosaic

Repository files navigation

Demosaic

Use GAN to remove mosaic.

Introduction in Chinese, please refer to 视频去马赛克.

Major innovations:

1. Automatic video processing;

2. The mosaic is generated randomly in the training process.

Getting Started

Prerequisites

  • Linux, Mac OS
  • Python 3.5+
  • ffmpeg 3.4.6
  • Pytorch 1.0+
  • NVIDIA GPU (11G memory or larger) + CUDA cuDNN

Dependencies

This code depends on opencv-python, torchvision, Matplotlib, dominate, and so on, available via pip install.

Clone this repo

git clone https://github.com/Z863058/demosaic
cd demosaic

Make training datasets

Use addmosaic model to make video datasets(Require addmosaic pre-trained model. This is better for processing video mosaics).

Train addmosaic pre-trained model, please refer to README_addmosaic.md.

cd z_make_datasets
python z_make_video_dataset.py --datadir x0.mp4 --savedir ../datasets/demosaic

Set training parameters

Modify the method get_random_parameter(img, mask) in z_util.mosaic.py.

Let the method produce the appropriate parameters of mosaic_size, mod and rect_rat to fit the mosaic video.

Training

python z_train.py --dataroot ./datasets/demosaic_20200501_286to256 --name demosaic_20200501_286to256_random --loadSize 286 --fineSize 256 --resize_or_crop crop --label_nc 0 --no_instance --niter 100 --niter_decay 100 --tf_log --gpu_ids 1 --continue_train

Testing

# for images
python z_test.py --dataroot ./datasets/demosaic_20200501_286to256 --name demosaic_20200501_286to256_random --loadSize 256 --fineSize 256 --label_nc 0 --no_instance --gpu_ids 0
# for video
python z_demosaic.py --name demosaic_20200501_286to256_random --media_path x.mp4

Acknowledgments

This code borrows heavily from [pix2pixHD] [DeepMosaics] [Pytorch-UNet] [BiSeNet].

More

更多(不可描述)信息,敬请微信搜索或扫码关注“天天P图AI”公众号。

Releases

No releases published

Packages

No packages published