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(directory_path) # 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)