README.md 6.2 KB
Newer Older
H
hypox64 已提交
1 2 3 4
<div align="center">
  <img src="./imgs/logo.png" width="250"><br><br>
  <img src="https://badgen.net/github/stars/hypox64/deepmosaics?icon=github&color=4ab8a1">&emsp;<img src="https://badgen.net/github/forks/hypox64/deepmosaics?icon=github&color=4ab8a1">&emsp;<a href="https://github.com/HypoX64/DeepMosaics/releases"><img src=https://img.shields.io/github/downloads/hypox64/deepmosaics/total></a>&emsp;<a href="https://github.com/HypoX64/DeepMosaics/releases"><img src=https://img.shields.io/github/v/release/hypox64/DeepMosaics></a>&emsp;<img src=https://img.shields.io/github/license/hypox64/deepmosaics>
</div>
H
hypox64 已提交
5

H
hypox64 已提交
6
# DeepMosaics
H
Harry Pham 已提交
7

H
hypox64 已提交
8 9
**English | [中文](./README_CN.md)**<br>
You can use it to automatically remove the mosaics in images and videos, or add mosaics to them.<br>This project is based on "semantic segmentation" and "Image-to-Image Translation".<br>Try it at this [website](http://118.89.27.46:5000/)!<br>
H
hypox64 已提交
10

H
hypox64 已提交
11
### Examples
H
Harry Pham 已提交
12

H
hypox64 已提交
13
![image](./imgs/hand.gif)
H
hypox64 已提交
14

H
Harry Pham 已提交
15 16 17 18
|                origin                |             auto add mosaic              |             auto clean mosaic              |
| :----------------------------------: | :--------------------------------------: | :----------------------------------------: |
|  ![image](./imgs/example/lena.jpg)   |  ![image](./imgs/example/lena_add.jpg)   |  ![image](./imgs/example/lena_clean.jpg)   |
| ![image](./imgs/example/youknow.png) | ![image](./imgs/example/youknow_add.png) | ![image](./imgs/example/youknow_clean.png) |
H
hypox64 已提交
19

H
Harry Pham 已提交
20
- Compared with [DeepCreamPy](https://github.com/deeppomf/DeepCreamPy)
H
hypox64 已提交
21

H
Harry Pham 已提交
22 23 24 25
|                mosaic image                |            DeepCreamPy             |                   ours                    |
| :----------------------------------------: | :--------------------------------: | :---------------------------------------: |
| ![image](./imgs/example/face_a_mosaic.jpg) | ![image](./imgs/example/a_dcp.png) | ![image](./imgs/example/face_a_clean.jpg) |
| ![image](./imgs/example/face_b_mosaic.jpg) | ![image](./imgs/example/b_dcp.png) | ![image](./imgs/example/face_b_clean.jpg) |
H
hypox64 已提交
26

H
Harry Pham 已提交
27
- Style Transfer
H
hypox64 已提交
28

H
Harry Pham 已提交
29 30 31
|              origin              |               to Van Gogh                |                   to winter                    |
| :------------------------------: | :--------------------------------------: | :--------------------------------------------: |
| ![image](./imgs/example/SZU.jpg) | ![image](./imgs/example/SZU_vangogh.jpg) | ![image](./imgs/example/SZU_summer2winter.jpg) |
H
hypox64 已提交
32

H
HypoX64 已提交
33
An interesting example:[Ricardo Milos to cat](https://www.bilibili.com/video/BV1Q7411W7n6)
H
hypox64 已提交
34

H
hypox64 已提交
35
## Run DeepMosaics
H
Harry Pham 已提交
36

37
You can either run DeepMosaics via a pre-built binary package, or from source.<br>
H
hypox64 已提交
38

H
hypox64 已提交
39
### Try it on web
H
Harry Pham 已提交
40

H
hypox64 已提交
41
You can simply try to remove the mosaic on the **face** at this [website](http://118.89.27.46:5000/).<br>
H
Harry Pham 已提交
42

H
hypox64 已提交
43
### Pre-built binary package
H
Harry Pham 已提交
44

45
For Windows, we bulid a GUI version for easy testing.<br>
H
Harry Pham 已提交
46
Download this version, and a pre-trained model via [[Google Drive]](https://drive.google.com/open?id=1LTERcN33McoiztYEwBxMuRjjgxh4DEPs) [[百度云,提取码1x0a]](https://pan.baidu.com/s/10rN3U3zd5TmfGpO_PEShqQ) <br>
H
hypox64 已提交
47

H
Harry Pham 已提交
48 49
- [[Help document]](./docs/exe_help.md)<br>
- Video tutorial => [[youtube]](https://www.youtube.com/watch?v=1kEmYawJ_vk) [[bilibili]](https://www.bilibili.com/video/BV1QK4y1a7Av)
H
hypox64 已提交
50

H
hypox64 已提交
51
![image](./imgs/GUI.png)<br>
H
hypox64 已提交
52
Attentions:<br>
H
HypoX64 已提交
53

H
Harry Pham 已提交
54 55 56 57 58
- Requires Windows_x86_64, Windows10 is better.<br>
- Different pre-trained models are suitable for different effects.[[Introduction to pre-trained models]](./docs/pre-trained_models_introduction.md)<br>
- Run time depends on computers performance (GPU version has better performance but requires CUDA to be installed).<br>
- If output video cannot be played, you can try with [potplayer](https://daumpotplayer.com/download/).<br>
- GUI version updates slower than source.<br>
H
hypox64 已提交
59

60
### Run From Source
H
Harry Pham 已提交
61

H
hypox64 已提交
62
#### Prerequisites
H
Harry Pham 已提交
63 64 65 66 67 68 69

- Linux, Mac OS, Windows
- Python 3.6+
- [ffmpeg 3.4.6](http://ffmpeg.org/)
- [Pytorch 1.0+](https://pytorch.org/)
- CPU or NVIDIA GPU + CUDA CuDNN<br>

H
hypox64 已提交
70
#### Dependencies
H
Harry Pham 已提交
71

H
hypox64 已提交
72
This code depends on opencv-python, torchvision available via pip install.
H
Harry Pham 已提交
73

H
hypox64 已提交
74
#### Clone this repo
H
Harry Pham 已提交
75

HypoX64's avatar
HypoX64 已提交
76
```bash
H
hypox64 已提交
77
git clone https://github.com/HypoX64/DeepMosaics.git
HypoX64's avatar
HypoX64 已提交
78
cd DeepMosaics
HypoX64's avatar
HypoX64 已提交
79
```
H
Harry Pham 已提交
80

81
#### Get Pre-Trained Models
H
Harry Pham 已提交
82

83
You can download pre_trained models and put them into './pretrained_models'.<br>
H
Harry Pham 已提交
84
[[Google Drive]](https://drive.google.com/open?id=1LTERcN33McoiztYEwBxMuRjjgxh4DEPs) [[百度云,提取码1x0a]](https://pan.baidu.com/s/10rN3U3zd5TmfGpO_PEShqQ)<br>
H
HypoX64 已提交
85
[[Introduction to pre-trained models]](./docs/pre-trained_models_introduction.md)<br>
H
hypox64 已提交
86

H
Harry Pham 已提交
87
In order to add/remove mosaic, there must be a model file `mosaic_position.pth` at `./pretrained_models/mosaic/mosaic_position.pth`
H
Harry Pham 已提交
88 89 90 91 92 93 94

#### Install dependencies

(Optional) Create a virtual environment

```bash
virtualenv mosaic
H
Harry Pham 已提交
95
source mosaic/bin/activate
H
Harry Pham 已提交
96 97 98 99 100 101 102 103 104 105
```

Then install the dependencies

```bash
pip install -r requirements.txt
```

If you can not build `scikit-image`, running `export CFLAGS='-Wno-implicit-function-declaration` then try to rebuild.

106
#### Simple Example
H
Harry Pham 已提交
107

H
Harry Pham 已提交
108
- Add Mosaic (output media will be saved in './result')<br>
H
Harry Pham 已提交
109

HypoX64's avatar
HypoX64 已提交
110
```bash
H
hypox64 已提交
111
python deepmosaic.py --media_path ./imgs/ruoruo.jpg --model_path ./pretrained_models/mosaic/add_face.pth --gpu_id 0
HypoX64's avatar
HypoX64 已提交
112
```
H
Harry Pham 已提交
113 114 115

- Clean Mosaic (output media will save in './result')<br>

HypoX64's avatar
HypoX64 已提交
116
```bash
H
hypox64 已提交
117
python deepmosaic.py --media_path ./result/ruoruo_add.jpg --model_path ./pretrained_models/mosaic/clean_face_HD.pth --gpu_id 0
HypoX64's avatar
HypoX64 已提交
118
```
H
Harry Pham 已提交
119

H
Harry Pham 已提交
120
If you see the error `Please check mosaic_position_model_path!`, check if there is a model file named `mosaic_position.pth` at `./pretrained_models/mosaic/mosaic_position.pth`
H
Harry Pham 已提交
121

122
#### More Parameters
H
Harry Pham 已提交
123

124
If you want to test other images or videos, please refer to this file.<br>
H
HypoX64 已提交
125
[[options_introduction.md]](./docs/options_introduction.md) <br>
H
hypox64 已提交
126

127
## Training With Your Own Dataset
H
Harry Pham 已提交
128

H
hypox64 已提交
129 130
If you want to train with your own dataset, please refer to [training_with_your_own_dataset.md](./docs/training_with_your_own_dataset.md)

131
## Acknowledgements
H
Harry Pham 已提交
132

H
hypox64 已提交
133
This code borrows heavily from [[pytorch-CycleGAN-and-pix2pix]](https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix) [[Pytorch-UNet]](https://github.com/milesial/Pytorch-UNet) [[pix2pixHD]](https://github.com/NVIDIA/pix2pixHD) [[BiSeNet]](https://github.com/ooooverflow/BiSeNet) [[DFDNet]](https://github.com/csxmli2016/DFDNet) [[GFRNet_pytorch_new]](https://github.com/sonack/GFRNet_pytorch_new).