Spaces:
Build error
Build error
Sophie98
commited on
Commit
•
b3e13eb
1
Parent(s):
f496440
try to fix error
Browse files- styleTransfer.py +8 -8
styleTransfer.py
CHANGED
@@ -15,11 +15,6 @@ import paddlehub as phub
|
|
15 |
|
16 |
############################################# TRANSFORMER ############################################
|
17 |
|
18 |
-
vgg_path = 'vgg_normalised.pth'
|
19 |
-
decoder_path = 'decoder_iter_160000.pth'
|
20 |
-
Trans_path = 'transformer_iter_160000.pth'
|
21 |
-
embedding_path = 'embedding_iter_160000.pth'
|
22 |
-
|
23 |
def style_transform(h,w):
|
24 |
k = (h,w)
|
25 |
transform_list = []
|
@@ -35,7 +30,10 @@ def content_transform():
|
|
35 |
return transform
|
36 |
|
37 |
def StyleTransformer(content_img: Image, style_img: Image):
|
38 |
-
|
|
|
|
|
|
|
39 |
# Advanced options
|
40 |
content_size=640
|
41 |
style_size=640
|
@@ -84,9 +82,10 @@ def StyleTransformer(content_img: Image, style_img: Image):
|
|
84 |
|
85 |
############################################## STYLE-GAN #############################################
|
86 |
|
87 |
-
style_transfer_model = tfhub.load("https://tfhub.dev/google/magenta/arbitrary-image-stylization-v1-256/2")
|
88 |
|
89 |
def StyleGAN(content_image, style_image):
|
|
|
|
|
90 |
content_image = tf.convert_to_tensor(content_image, np.float32)[tf.newaxis, ...] / 255.
|
91 |
style_image = tf.convert_to_tensor(style_image, np.float32)[tf.newaxis, ...] / 255.
|
92 |
output = style_transfer_model(content_image, style_image)
|
@@ -95,9 +94,10 @@ def StyleGAN(content_image, style_image):
|
|
95 |
|
96 |
########################################### STYLE PROJECTION ##########################################
|
97 |
|
98 |
-
|
99 |
|
100 |
def styleProjection(content_image,style_image):
|
|
|
101 |
result = stylepro_artistic.style_transfer(
|
102 |
images=[{
|
103 |
'content': np.array(content_image.convert('RGB') )[:, :, ::-1],
|
|
|
15 |
|
16 |
############################################# TRANSFORMER ############################################
|
17 |
|
|
|
|
|
|
|
|
|
|
|
18 |
def style_transform(h,w):
|
19 |
k = (h,w)
|
20 |
transform_list = []
|
|
|
30 |
return transform
|
31 |
|
32 |
def StyleTransformer(content_img: Image, style_img: Image):
|
33 |
+
vgg_path = 'vgg_normalised.pth'
|
34 |
+
decoder_path = 'decoder_iter_160000.pth'
|
35 |
+
Trans_path = 'transformer_iter_160000.pth'
|
36 |
+
embedding_path = 'embedding_iter_160000.pth'
|
37 |
# Advanced options
|
38 |
content_size=640
|
39 |
style_size=640
|
|
|
82 |
|
83 |
############################################## STYLE-GAN #############################################
|
84 |
|
|
|
85 |
|
86 |
def StyleGAN(content_image, style_image):
|
87 |
+
style_transfer_model = tfhub.load("https://tfhub.dev/google/magenta/arbitrary-image-stylization-v1-256/2")
|
88 |
+
|
89 |
content_image = tf.convert_to_tensor(content_image, np.float32)[tf.newaxis, ...] / 255.
|
90 |
style_image = tf.convert_to_tensor(style_image, np.float32)[tf.newaxis, ...] / 255.
|
91 |
output = style_transfer_model(content_image, style_image)
|
|
|
94 |
|
95 |
########################################### STYLE PROJECTION ##########################################
|
96 |
|
97 |
+
|
98 |
|
99 |
def styleProjection(content_image,style_image):
|
100 |
+
stylepro_artistic = phub.Module(name="stylepro_artistic")
|
101 |
result = stylepro_artistic.style_transfer(
|
102 |
images=[{
|
103 |
'content': np.array(content_image.convert('RGB') )[:, :, ::-1],
|