Spaces:
Running
on
T4
Running
on
T4
File size: 1,459 Bytes
4045a73 865ddb0 4045a73 e46cbc4 4045a73 1688517 4045a73 aad4b49 ef9c3f5 5a5aa5d ef9c3f5 4045a73 ef9c3f5 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 27 28 29 30 31 32 33 34 35 36 |
import gradio as gr
import subprocess
import os
def generate(image, prompt, seed):
print(image, prompt, seed)
command = f"python handrefiner.py --input_img {image} --out_dir output --strength 0.55 --weights 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 = 'output'
print("Output:", result.stdout)
print(output_path)
# List all files and directories in the given directory
contents = os.listdir("output")
# Print the contents
for item in contents:
print(item)
return "Done"
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)
output_image = gr.Textbox()
button.click(fn=generate, inputs=[image, textbox, seed], outputs=[output_image])
demo.queue().launch(inline=False, share=True, debug=True) |