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