-
Notifications
You must be signed in to change notification settings - Fork 1
/
final_generate.py
executable file
·52 lines (37 loc) · 1.42 KB
/
final_generate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 07 20:56:25 2017
@author: Administrator
"""
import numpy as np
from argparse import ArgumentParser
from skimage.io import imread,imshow,imsave
def build_parser():
parser = ArgumentParser()
parser.add_argument('--content', type=str,
dest='content', help='content image path',
metavar='CONTENT', required=True)
parser.add_argument('--mask', type=str,
dest='mask',
help='mask image path',
metavar='Mask', required= True)
parser.add_argument('--stylized', type=str,
dest='stylized',
help='path for stylized image',
metavar='stylized_PATH', required=True)
parser.add_argument('--output-path', type=str,
dest='output_path',
help='path for output',
metavar='output_PATH', required=True)
return parser
def generate_final():
parser = build_parser()
options = parser.parse_args()
yc= imread(options.content)
mask = imread(options.mask)/220
mask = np.expand_dims(mask,axis=2)
yg= imread(options.stylized)
yf=yg*mask+yc*(-mask+1)
imsave(options.output_path,yf)
if __name__ == '__main__':
generate_final()