Ahsen Khaliq commited on
Commit
34974b2
1 Parent(s): f32ad99

add version 0.4

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -2,6 +2,7 @@ import pystuck
2
  pystuck.run_server()
3
  import os
4
  os.system("pip install gradio==2.5.3")
 
5
  os.system("wget https://github.com/Sxela/ArcaneGAN/releases/download/v0.3/ArcaneGANv0.3.jit")
6
  os.system("wget https://github.com/Sxela/ArcaneGAN/releases/download/v0.2/ArcaneGANv0.2.jit")
7
  os.system("pip -qq install facenet_pytorch")
@@ -128,11 +129,15 @@ def fit(img,maxsize=512):
128
  img = img.resize(size)
129
  return img
130
 
 
131
  modelv3 = torch.jit.load('./ArcaneGANv0.3.jit').eval().cuda().half()
132
  modelv2 = torch.jit.load('./ArcaneGANv0.2.jit').eval().cuda().half()
133
 
134
  def process(im, version):
135
- if version == 'version 0.3':
 
 
 
136
  im = scale_by_face_size(im, target_face=300, max_res=1_500_000, max_upscale=2)
137
  res = proc_pil_img(im, modelv3)
138
  else:
@@ -146,7 +151,7 @@ article = "<div style='text-align: center;'>ArcaneGan by <a href='https://twitte
146
 
147
  gr.Interface(
148
  process,
149
- [gr.inputs.Image(type="pil", label="Input",shape=(256,256)),gr.inputs.Radio(choices=['version 0.2','version 0.3'], type="value", default='version 0.3', label='version')
150
  ],
151
  gr.outputs.Image(type="pil", label="Output"),
152
  title=title,
 
2
  pystuck.run_server()
3
  import os
4
  os.system("pip install gradio==2.5.3")
5
+ os.system("wget https://github.com/Sxela/ArcaneGAN/releases/download/v0.4/ArcaneGANv0.4.jit")
6
  os.system("wget https://github.com/Sxela/ArcaneGAN/releases/download/v0.3/ArcaneGANv0.3.jit")
7
  os.system("wget https://github.com/Sxela/ArcaneGAN/releases/download/v0.2/ArcaneGANv0.2.jit")
8
  os.system("pip -qq install facenet_pytorch")
 
129
  img = img.resize(size)
130
  return img
131
 
132
+ modelv4 = torch.jit.load('./ArcaneGANv0.4.jit').eval().cuda().half()
133
  modelv3 = torch.jit.load('./ArcaneGANv0.3.jit').eval().cuda().half()
134
  modelv2 = torch.jit.load('./ArcaneGANv0.2.jit').eval().cuda().half()
135
 
136
  def process(im, version):
137
+ if version == 'version 0.4':
138
+ im = scale_by_face_size(im, target_face=300, max_res=1_500_000, max_upscale=2)
139
+ res = proc_pil_img(im, modelv4)
140
+ elif version == 'version 0.3':
141
  im = scale_by_face_size(im, target_face=300, max_res=1_500_000, max_upscale=2)
142
  res = proc_pil_img(im, modelv3)
143
  else:
 
151
 
152
  gr.Interface(
153
  process,
154
+ [gr.inputs.Image(type="pil", label="Input",shape=(256,256)),gr.inputs.Radio(choices=['version 0.2','version 0.3','version 0.4'], type="value", default='version 0.4', label='version')
155
  ],
156
  gr.outputs.Image(type="pil", label="Output"),
157
  title=title,