File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -31,9 +31,19 @@ We only tested our code in the following environment.
31
31
32
32
### Download pretrained networks
33
33
34
+ ** PyTorch models**
35
+
36
+ These models are extracted from Torch7 models and currently used in the project.
37
+
38
+ - Pull them from the ` PhotoWCTModels ` submodule: ` git submodule update --init --recursive `
39
+
40
+ ** Origin Torch7 models**
41
+
34
42
- Download pretrained networks via the following [ link] ( https://drive.google.com/open?id=1ENgQm9TgabE1R99zhNf5q6meBvX6WFuq ) .
35
43
- Unzip and store the model files under ` models ` .
36
44
45
+ ` converter.py ` shows how to convert Torth7 models to PyTorch models.
46
+
37
47
### Example 1: Transfer the style of a style photo to a content photo.
38
48
- Create image and output folders and make sure nothing is inside the folders. ` mkdir images && mkdir results `
39
49
- Go to the image folder: ` cd images `
Original file line number Diff line number Diff line change 3
3
Licensed under the CC BY-NC-SA 4.0 license (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).
4
4
"""
5
5
6
+ from __future__ import print_function
6
7
import argparse
7
8
8
9
import torch
11
12
from photo_wct import PhotoWCT
12
13
13
14
parser = argparse .ArgumentParser (description = 'Photorealistic Image Stylization' )
14
- parser .add_argument ('--model' , default = './PhotoWCTModels/photo_wct.pth' , help = 'Path to the PhotoWCT model' )
15
+ parser .add_argument ('--model' , default = './PhotoWCTModels/photo_wct.pth' ,
16
+ help = 'Path to the PhotoWCT model. These are provided by the PhotoWCT submodule, please use `git submodule update --init --recursive` to pull.' )
15
17
parser .add_argument ('--content_image_path' , default = './images/content1.png' )
16
18
parser .add_argument ('--content_seg_path' , default = [])
17
19
parser .add_argument ('--style_image_path' , default = './images/style1.png' )
21
23
22
24
# Load model
23
25
p_wct = PhotoWCT ()
24
- p_wct .load_state_dict (torch .load (args .model ))
26
+ try :
27
+ p_wct .load_state_dict (torch .load (args .model ))
28
+ except :
29
+ print ("Fail to load PhotoWCT models. PhotoWCT submodule not updated?" )
30
+ exit ()
31
+
25
32
p_wct .cuda (0 )
26
33
27
34
process_stylization .stylization (
Original file line number Diff line number Diff line change 3
3
Licensed under the CC BY-NC-SA 4.0 license (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).
4
4
"""
5
5
6
+ from __future__ import print_function
6
7
import argparse
7
8
import os
8
9
12
13
import process_stylization
13
14
14
15
parser = argparse .ArgumentParser (description = 'Photorealistic Image Stylization' )
15
- parser .add_argument ('--model' , default = './PhotoWCTModels/photo_wct.pth' , help = 'Path to the PhotoWCT model' )
16
+ parser .add_argument ('--model' , default = './PhotoWCTModels/photo_wct.pth' ,
17
+ help = 'Path to the PhotoWCT model. These are provided by the PhotoWCT submodule, please use `git submodule update --init --recursive` to pull.' )
16
18
args = parser .parse_args ()
17
19
18
20
folder = 'examples'
You can’t perform that action at this time.
0 commit comments