fffiloni commited on
Commit
4045a73
·
1 Parent(s): f680fbd

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import subprocess
3
+
4
+ def generate(image, prompt, seed):
5
+ print(image, prompt, seed)
6
+ 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}"
7
+ try:
8
+ result = subprocess.run(command, shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
9
+ output_path = '/content/HandRefiner/output/image_0.jpg'
10
+ print("Output:", result.stdout)
11
+ return output_path
12
+ except subprocess.CalledProcessError as e:
13
+ print("Error:", e.stderr)
14
+ return None
15
+
16
+ with gr.Blocks() as demo:
17
+ with gr.Row():
18
+ with gr.Column():
19
+ image = gr.Image(type='filepath')
20
+ textbox = gr.Textbox(show_label=False, value="a person facing the camera, making a hand gesture, indoor")
21
+ seed = gr.Slider(minimum=0, maximum=1000000, value=643534)
22
+ button = gr.Button()
23
+ output_image = gr.Image(show_label=False, type="filepath", interactive=False, height=512, width=512)
24
+ button.click(fn=generate, inputs=[image, textbox, seed], outputs=[output_image])
25
+
26
+ demo.queue().launch(inline=False, share=True, debug=True)