|
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)
|
|
return img
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate_model(img):
|
|
|
|
print("about to die")
|
|
iface = gr.Interface.load("spaces/radames/PIFu-Clothed-Human-Digitization")
|
|
print("calling interface")
|
|
|
|
model,file=iface(img)
|
|
|
|
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')
|
|
|
|
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) |