Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -122,30 +122,44 @@ modelv4 = torch.jit.load(modelarcanev4,map_location='cpu').eval().cpu().half().f
|
|
122 |
modelv3 = torch.jit.load(modelarcanev3,map_location='cpu').eval().cpu().half().float()
|
123 |
modelv2 = torch.jit.load(modelarcanev2,map_location='cpu').eval().cpu().half().float()
|
124 |
|
125 |
-
def
|
126 |
-
|
127 |
-
|
128 |
-
res = proc_pil_img(im, modelv4)
|
129 |
-
elif version == 'version 0.3':
|
130 |
-
im = scale_by_face_size(im, target_face=256, max_res=1_500_000, max_upscale=1)
|
131 |
-
res = proc_pil_img(im, modelv3)
|
132 |
-
else:
|
133 |
-
im = scale_by_face_size(im, target_face=256, max_res=1_500_000, max_upscale=1)
|
134 |
-
res = proc_pil_img(im, modelv2)
|
135 |
return res
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
modelv3 = torch.jit.load(modelarcanev3,map_location='cpu').eval().cpu().half().float()
|
123 |
modelv2 = torch.jit.load(modelarcanev2,map_location='cpu').eval().cpu().half().float()
|
124 |
|
125 |
+
def version4(img):
|
126 |
+
im = scale_by_face_size(im, target_face=256, max_res=1_500_000, max_upscale=1)
|
127 |
+
res = proc_pil_img(im, modelv4)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
return res
|
129 |
+
|
130 |
+
def version3(img):
|
131 |
+
im = scale_by_face_size(im, target_face=256, max_res=1_500_000, max_upscale=1)
|
132 |
+
res = proc_pil_img(im, modelv3)
|
133 |
+
return res
|
134 |
+
|
135 |
+
def version2(img):
|
136 |
+
im = scale_by_face_size(im, target_face=256, max_res=1_500_000, max_upscale=1)
|
137 |
+
res = proc_pil_img(im, modelv2)
|
138 |
+
return res
|
139 |
+
|
140 |
+
block = gr.Blocks()
|
141 |
+
|
142 |
+
with block:
|
143 |
+
gr.Markdown("Gradio Demo for ArcaneGAN, portrait to Arcane style. To use it, simply upload your image. Try out the different versions by clicking on the tabs. Please use a cropped portrait picture for best results.")
|
144 |
+
|
145 |
+
with gr.Tab("version four"):
|
146 |
+
with gr.Row():
|
147 |
+
facepaint4 = gr.inputs.Image(type="pil",shape=(512,512))
|
148 |
+
faceout4 = gr.outputs.Image(type="pil")
|
149 |
+
face_run = gr.Button("Run")
|
150 |
+
face_run.click(version4, inputs=facepaint4, outputs=faceout4)
|
151 |
+
|
152 |
+
with gr.Tab("version three"):
|
153 |
+
with gr.Row():
|
154 |
+
facepaint3 = gr.inputs.Image(type="pil")
|
155 |
+
faceout3 = gr.outputs.Image(type="pil")
|
156 |
+
face_run = gr.Button("Run")
|
157 |
+
face_run.click(version3, inputs=facepaint3, outputs=faceout3)
|
158 |
+
with gr.Tab("version two"):
|
159 |
+
with gr.Row():
|
160 |
+
facepaint2 = gr.inputs.Image(type="pil")
|
161 |
+
faceout2 = gr.outputs.Image(type="pil")
|
162 |
+
face_run = gr.Button("Run")
|
163 |
+
face_run.click(version2, inputs=facepaint2, outputs=faceout2)
|
164 |
+
|
165 |
+
block.launch(enable_queue=True)
|