HandRefiner / app.py
fffiloni's picture
Create app.py
4045a73
raw
history blame
1.26 kB
import gradio as gr
import subprocess
def generate(image, prompt, seed):
print(image, prompt, seed)
command = f"python handrefiner.py --input_img {image} --out_dir /content/HandRefiner/output --strength 0.55 --weights /content/HandRefiner/models/inpaint_depth_control.ckpt --prompt '{prompt}' --seed {seed}"
try:
result = subprocess.run(command, shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
output_path = '/content/HandRefiner/output/image_0.jpg'
print("Output:", result.stdout)
return output_path
except subprocess.CalledProcessError as e:
print("Error:", e.stderr)
return None
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
image = gr.Image(type='filepath')
textbox = gr.Textbox(show_label=False, value="a person facing the camera, making a hand gesture, indoor")
seed = gr.Slider(minimum=0, maximum=1000000, value=643534)
button = gr.Button()
output_image = gr.Image(show_label=False, type="filepath", interactive=False, height=512, width=512)
button.click(fn=generate, inputs=[image, textbox, seed], outputs=[output_image])
demo.queue().launch(inline=False, share=True, debug=True)