Logan Zoellner commited on
Commit
bf7395c
1 Parent(s): 3599c2c

try converting to numpy

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -2,25 +2,32 @@ from asyncio import constants
2
  import gradio as gr
3
  import requests
4
  import os
 
 
 
5
 
6
 
7
  def generate_image(seed,psi):
8
  iface = gr.Interface.load("spaces/hysts/StyleGAN-Human")
9
  print("about to die",iface,dir(iface))
10
  print(iface.blocks,iface.children,iface.fns)
11
- img=iface.fns[1].fn(seed,psi)
12
-
 
 
 
 
 
 
13
  print('got img',img)
14
 
15
- return img
16
 
17
  def generate_model(img):
18
- d
19
  model,file=iface(img)
20
  return model,file
21
 
22
- def foo(seed,psi):
23
- return img
24
 
25
  demo = gr.Blocks()
26
 
 
2
  import gradio as gr
3
  import requests
4
  import os
5
+ from base64 import b64decode
6
+ from PIL import Image
7
+
8
 
9
 
10
  def generate_image(seed,psi):
11
  iface = gr.Interface.load("spaces/hysts/StyleGAN-Human")
12
  print("about to die",iface,dir(iface))
13
  print(iface.blocks,iface.children,iface.fns)
14
+ img=iface.fns[0].fn(seed,psi)
15
+
16
+ #wrong format, gah! convert to numpy array
17
+ header, encoded = img.split(",", 1)
18
+ data = b64decode(encoded)
19
+ image = Image.open("out.jpg")
20
+ image_np = np.array(image)
21
+
22
  print('got img',img)
23
 
24
+ return image_np
25
 
26
  def generate_model(img):
27
+ iface = gr.Interface.load("spaces/nagolinc/styleGanHuman_and_PIFu")
28
  model,file=iface(img)
29
  return model,file
30
 
 
 
31
 
32
  demo = gr.Blocks()
33