Update app.py
Browse files
app.py
CHANGED
@@ -49,7 +49,7 @@ def display_gif_pad(file_name, save_name):
|
|
49 |
image_filename = file_name + frame_name + '.png'
|
50 |
image = imageio.imread(image_filename)
|
51 |
image = image[:, :, :3]
|
52 |
-
image_pad = cv2.copyMakeBorder(image, 0, 0,
|
53 |
images.append(image_pad)
|
54 |
|
55 |
gif_filename = 'avatar_source.gif'
|
@@ -64,11 +64,13 @@ def display_image(file_name):
|
|
64 |
imageio.imwrite('image.png', image)
|
65 |
|
66 |
|
67 |
-
def run(action,
|
68 |
|
|
|
69 |
# body
|
70 |
-
if body == "human":
|
71 |
-
elif body == "alien": body = '1'
|
|
|
72 |
|
73 |
# hair
|
74 |
if hair == "green": hair = '0'
|
@@ -93,20 +95,31 @@ def run(action, body, hair, top, bottom):
|
|
93 |
|
94 |
gif = display_gif_pad(file_name_source, 'avatar_source.gif')
|
95 |
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
|
99 |
gr.Interface(
|
100 |
run,
|
101 |
inputs=[
|
102 |
gr.Radio(choices=["shoot", "slash", "spellcard", "thrust", "walk"], value="shoot"),
|
103 |
-
gr.Radio(choices=["human", "alien"], value="human"),
|
104 |
gr.Radio(choices=["green", "yellow", "rose", "red", "wine"], value="green"),
|
105 |
gr.Radio(choices=["brown", "blue", "white"], value="brown"),
|
106 |
gr.Radio(choices=["white", "golden", "red", "silver"], value="white"),
|
107 |
],
|
108 |
outputs=[
|
109 |
-
gr.components.Image(type="file", label="Avatar (
|
|
|
110 |
],
|
111 |
live=True,
|
112 |
title="TransferVAE for Unsupervised Video Domain Adaptation",
|
|
|
49 |
image_filename = file_name + frame_name + '.png'
|
50 |
image = imageio.imread(image_filename)
|
51 |
image = image[:, :, :3]
|
52 |
+
image_pad = cv2.copyMakeBorder(image, 0, 0, 100, 100, cv2.BORDER_CONSTANT, value=0)
|
53 |
images.append(image_pad)
|
54 |
|
55 |
gif_filename = 'avatar_source.gif'
|
|
|
64 |
imageio.imwrite('image.png', image)
|
65 |
|
66 |
|
67 |
+
def run(action, hair, top, bottom):
|
68 |
|
69 |
+
# == Source Avatar ==
|
70 |
# body
|
71 |
+
#if body == "human":body = '0'
|
72 |
+
#elif body == "alien": body = '1'
|
73 |
+
body = '0'
|
74 |
|
75 |
# hair
|
76 |
if hair == "green": hair = '0'
|
|
|
95 |
|
96 |
gif = display_gif_pad(file_name_source, 'avatar_source.gif')
|
97 |
|
98 |
+
# == Target Avatar ==
|
99 |
+
body_target = '1'
|
100 |
+
hair_target = np.random.choice('1', '3', '5', '6', '9')
|
101 |
+
top_target = np.random.choice('3', '4', '5', '6')
|
102 |
+
bottom_target = np.random.choice('4', '5', '6')
|
103 |
+
|
104 |
+
file_name_target = './Sprite/frames/domain_2/' + action + '/'
|
105 |
+
file_name_target = file_name_target + 'front' + '_' + str(body_target) + str(bottom_target) + str(top_target) + str(hair_target) + '_'
|
106 |
+
|
107 |
+
gif = display_gif_pad(file_name_target, 'avatar_target.gif')
|
108 |
+
|
109 |
+
return 'avatar_source.gif', 'avatar_target.gif'
|
110 |
|
111 |
|
112 |
gr.Interface(
|
113 |
run,
|
114 |
inputs=[
|
115 |
gr.Radio(choices=["shoot", "slash", "spellcard", "thrust", "walk"], value="shoot"),
|
|
|
116 |
gr.Radio(choices=["green", "yellow", "rose", "red", "wine"], value="green"),
|
117 |
gr.Radio(choices=["brown", "blue", "white"], value="brown"),
|
118 |
gr.Radio(choices=["white", "golden", "red", "silver"], value="white"),
|
119 |
],
|
120 |
outputs=[
|
121 |
+
gr.components.Image(type="file", label="Source Avatar (Costumed by You)"),
|
122 |
+
gr.components.Image(type="file", label="Target Avatar (Randomly Chosen)"),
|
123 |
],
|
124 |
live=True,
|
125 |
title="TransferVAE for Unsupervised Video Domain Adaptation",
|