提交 a3ecbfd9 编写于 作者: H hypox64

I'm back

上级 b4d5c316
......@@ -3,16 +3,14 @@
You can use it to automatically remove the mosaics in images and videos, or add mosaics to them.<br>
This porject based on semantic segmentation and pix2pix.
<br>
## Notes
The code do not include the part of training, I will finish it in my free time.
<br>
## Prerequisites
- Linux, (I didn't try this code on Windows or Mac OS)
- Python 3.6+
- Linux, (I didn't try this code on Windows or mac machine)
- Python 3.5+
- ffmpeg
- Pytorch 1.0+ [(Old version codes)](https://github.com/HypoX64/DeepMosaics/tree/Pytorch0.4)
- Pytroch 0.4, (I will update to 1.0)
- CPU or NVIDIA GPU + CUDA CuDNN
## Getting Started
......@@ -23,9 +21,8 @@ cd DeepMosaics
```
### Get pre_trained models and test video
You can download pre_trained models and test video and replace the files in the project.<br>
[[Google Drive]](https://drive.google.com/open?id=10nARsiZoZGcaKw40nQu9fJuRp1oeabPs)
[[百度云,提取码7thu]](https://pan.baidu.com/s/1IG4bdIiIC9PH9-oEyae5Sg)
[[Google Drive]](https://drive.google.com/open?id=1PXt3dE9Eez2xUqpemLJutwTCC0tW-D2g)
[[百度云,提取码z8vz]](https://pan.baidu.com/s/1Wi8T6PE4ExTjrHVQhv3rJA)
### Dependencies
This code depends on numpy, scipy, opencv-python, torchvision, available via pip install.
### AddMosaic
......
......@@ -3,14 +3,15 @@ from .pix2pix_model import *
from .unet_model import UNet
def pix2pix(model_path,G_model_type,use_gpu = True):
gpu_ids=[]
netG = define_G(3, 3, 64, G_model_type, norm='batch', init_type='normal', gpu_ids=gpu_ids)
netG = define_G(3, 3, 64, G_model_type, norm='batch',use_dropout=True, init_type='normal', gpu_ids=[])
netG.load_state_dict(torch.load(model_path))
netG.eval()
if use_gpu:
netG.cuda()
return netG
def unet(model_path,use_gpu = True):
net = UNet(n_channels = 3, n_classes = 1)
net.load_state_dict(torch.load(model_path))
......
# This code clone from https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix
# LICENSE file : https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/blob/master/LICENSE
import torch
import torch.nn as nn
from torch.nn import init
......
# This code clone from https://github.com/milesial/Pytorch-UNet
# LICENSE file : https://github.com/milesial/Pytorch-UNet/blob/master/LICENSE
# full assembly of the sub-parts to form the complete net
import torch.nn.functional as F
from .unet_parts import *
class UNet(nn.Module):
......
# sub-parts of the U-Net model
# This code clone from https://github.com/milesial/Pytorch-UNet
# LICENSE file : https://github.com/milesial/Pytorch-UNet/blob/master/LICENSE
# sub-parts of the U-Net model
import torch
import torch.nn as nn
import torch.nn.functional as F
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册