akhaliq HF staff commited on
Commit
aa20d61
1 Parent(s): 1938333

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -26
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 process(im, version):
126
- if version == 'version 0.4':
127
- im = scale_by_face_size(im, target_face=256, max_res=1_500_000, max_upscale=1)
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
- title = "ArcaneGAN"
138
- description = "Gradio demo for ArcaneGAN, portrait to Arcane style. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
139
- article = "<div style='text-align: center;'>ArcaneGan by <a href='https://twitter.com/devdef' target='_blank'>Alexander S</a> | <a href='https://github.com/Sxela/ArcaneGAN' target='_blank'>Github Repo</a> | <center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_arcanegan' alt='visitor badge'></center></div>"
140
-
141
- gr.Interface(
142
- process,
143
- [gr.inputs.Image(type="pil", label="Input"),gr.inputs.Radio(choices=['version 0.2','version 0.3','version 0.4'], type="value", default='version 0.4', label='version')
144
- ],
145
- gr.outputs.Image(type="pil", label="Output"),
146
- title=title,
147
- description=description,
148
- article=article,
149
- allow_flagging=False,
150
- allow_screenshot=False
151
- ).launch(enable_queue=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)