RamAnanth1 commited on
Commit
fb44af1
1 Parent(s): e5a3226

Create gradio_seg.py

Browse files
Files changed (1) hide show
  1. gradio_seg.py +32 -0
gradio_seg.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def create_demo(process):
4
+ block = gr.Blocks().queue()
5
+ with block:
6
+ with gr.Row():
7
+ with gr.Column():
8
+ input_img = gr.Image(source='upload', type="numpy")
9
+ prompt = gr.Textbox(label="Prompt")
10
+ neg_prompt = gr.Textbox(label="Negative Prompt",
11
+ value='ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, disfigured, deformed, body out of frame, bad anatomy, watermark, signature, cut off, low contrast, underexposed, overexposed, bad art, beginner, amateur, distorted face')
12
+ run_button = gr.Button(label="Run")
13
+ with gr.Accordion("Advanced options", open=False):
14
+ con_strength = gr.Slider(label="Controling Strength (The guidance strength of the sketch to the result)", minimum=0, maximum=1, value=0.4, step=0.1)
15
+ scale = gr.Slider(label="Guidance Scale (Classifier free guidance)", minimum=0.1, maximum=30.0, value=7.5, step=0.1)
16
+ fix_sample = gr.inputs.Radio(['True', 'False'], type="value", default='False', label='Fix Sampling\n (Fix the random seed)')
17
+ base_model = gr.inputs.Radio(['sd-v1-4.ckpt', 'anything-v4.0-pruned.ckpt'], type="value", default='sd-v1-4.ckpt', label='The base model you want to use')
18
+ with gr.Column():
19
+ result = gr.Gallery(label='Output', show_label=False, elem_id="gallery").style(grid=2, height='auto')
20
+ ips = [input_img,prompt, neg_prompt, fix_sample, scale, con_strength, base_model]
21
+ run_button.click(fn=process, inputs=ips, outputs=[result])
22
+
23
+ examples_list = [["motor.png", "A black Honda motorcycle parked in front of a garage",
24
+ "ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, disfigured, deformed, body out of frame, bad anatomy, watermark, signature, cut off, low contrast, underexposed, overexposed, bad art, beginner, amateur, distorted face",
25
+ 'True',
26
+ 7.5,
27
+ 0.4,
28
+ 'anything-v4.0-pruned.ckpt']]
29
+
30
+ examples = gr.Examples(examples=examples_list,inputs = [input_img, prompt,neg_prompt, fix_sample, scale, con_strength,base_model], outputs = [result], cache_examples = True, fn = process)
31
+
32
+ return block