Spaces:
Sleeping
Sleeping
File size: 1,262 Bytes
4045a73 |
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 |
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) |