nagolinc commited on
Commit
2c45f04
1 Parent(s): 92a7f0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -61
app.py CHANGED
@@ -1,62 +1,62 @@
1
- from asyncio import constants
2
- import gradio as gr
3
- import requests
4
- import os
5
- from base64 import b64decode
6
- from PIL import Image
7
- import io
8
- import numpy as np
9
-
10
-
11
- def generate_image(seed,psi):
12
- iface = gr.Interface.load("spaces/hysts/StyleGAN-Human")
13
-
14
- print("calling interface",seed,psi)
15
- img=iface(seed,psi)
16
- return img
17
-
18
- #img=iface.fns[0].fn(seed,psi)
19
- #wrong format, gah! convert to numpy array
20
- #header, encoded = img.split(",", 1)
21
- #data = b64decode(encoded)
22
- #image = Image.open(io.BytesIO(data))
23
- #image_np = np.array(image)
24
- #return image_np
25
-
26
- def generate_model(img):
27
-
28
- print("about to die")
29
- iface = gr.Interface.load("spaces/radames/PIFu-Clothed-Human-Digitization")
30
- print("calling interface")
31
- #model,file=iface.fns[0].fn(img)
32
- model,file=iface(img)
33
- #print("got result",result)
34
- return model,file
35
-
36
-
37
- demo = gr.Blocks()
38
-
39
- with demo:
40
- gr.Markdown("<h1><center>StyleGan-Human + PIFu </center></h1>")
41
- gr.Markdown(
42
- "create a person and then generate a model from that person's image"
43
- )
44
-
45
-
46
- with gr.Row():
47
- b0 = gr.Button("generate image")
48
- b1 = gr.Button("generate model")
49
-
50
- with gr.Row():
51
- seed=gr.Number(default=0, label='Seed')
52
- psi=gr.inputs.Slider(0, 2, step=0.05, default=0.7, label='Truncation psi')
53
- #outputImage = gr.Image(label="portrait",type="filepath", shape=(256,256))
54
- output_image = gr.outputs.Image(type="filepath", label='Output')
55
- model = gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="3D Model")
56
- file= gr.File(label="Download 3D Model")
57
-
58
-
59
- b0.click(generate_image,inputs=[seed,psi],outputs=output_image)
60
- b1.click(generate_model, inputs=output_image, outputs=[model,file])
61
-
62
  demo.launch(enable_queue=True, debug=True)
 
1
+ from asyncio import constants
2
+ import gradio as gr
3
+ import requests
4
+ import os
5
+ from base64 import b64decode
6
+ from PIL import Image
7
+ import io
8
+ import numpy as np
9
+
10
+
11
+ def generate_image(seed,psi):
12
+ iface = gr.Interface.load("spaces/hysts/StyleGAN-Human")
13
+
14
+ print("calling interface",seed,psi)
15
+ img=iface(seed,psi)
16
+ return img
17
+
18
+ #img=iface.fns[0].fn(seed,psi)
19
+ #wrong format, gah! convert to numpy array
20
+ #header, encoded = img.split(",", 1)
21
+ #data = b64decode(encoded)
22
+ #image = Image.open(io.BytesIO(data))
23
+ #image_np = np.array(image)
24
+ #return image_np
25
+
26
+ def generate_model(img):
27
+
28
+ print("about to die")
29
+ iface = gr.Interface.load("spaces/radames/PIFu-Clothed-Human-Digitization")
30
+ print("calling interface")
31
+ #model,file=iface.fns[0].fn(img)
32
+ model,file=iface(img)
33
+ #print("got result",result)
34
+ return model,file
35
+
36
+
37
+ demo = gr.Blocks()
38
+
39
+ with demo:
40
+ gr.Markdown("<h1><center>StyleGan-Human + PIFu </center></h1>")
41
+ gr.Markdown(
42
+ "create a person and then generate a model from that person's image"
43
+ )
44
+
45
+
46
+ with gr.Row():
47
+ b0 = gr.Button("generate image")
48
+ b1 = gr.Button("generate model")
49
+
50
+ with gr.Row():
51
+ seed=gr.Number(value=0, label='Seed')
52
+ psi=gr.inputs.Slider(0, 2, step=0.05, value=0.7, label='Truncation psi')
53
+ #outputImage = gr.Image(label="portrait",type="filepath", shape=(256,256))
54
+ output_image = gr.outputs.Image(type="filepath", label='Output')
55
+ model = gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="3D Model")
56
+ file= gr.File(label="Download 3D Model")
57
+
58
+
59
+ b0.click(generate_image,inputs=[seed,psi],outputs=output_image)
60
+ b1.click(generate_model, inputs=output_image, outputs=[model,file])
61
+
62
  demo.launch(enable_queue=True, debug=True)