RamAnanth1 commited on
Commit
e893bfe
1 Parent(s): 9491a3e

Create gradio_sketch.py

Browse files
Files changed (1) hide show
  1. gradio_sketch.py +29 -0
gradio_sketch.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+
4
+ def create_demo(process):
5
+ block = gr.Blocks().queue()
6
+ with block:
7
+ with gr.Row():
8
+ gr.Markdown(DESCRIPTION)
9
+ with gr.Row():
10
+ with gr.Column():
11
+ input_img = gr.Image(source='upload', type="numpy")
12
+ prompt = gr.Textbox(label="Prompt")
13
+ neg_prompt = gr.Textbox(label="Negative Prompt",
14
+ 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')
15
+ with gr.Row():
16
+ type_in = gr.inputs.Radio(['Sketch', 'Image'], type="value", default='Image', label='Input Types\n (You can input an image or a sketch)')
17
+ color_back = gr.inputs.Radio(['White', 'Black'], type="value", default='Black', label='Color of the sketch background\n (Only work for sketch input)')
18
+ run_button = gr.Button(label="Run")
19
+ 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)
20
+ scale = gr.Slider(label="Guidance Scale (Classifier free guidance)", minimum=0.1, maximum=30.0, value=7.5, step=0.1)
21
+ fix_sample = gr.inputs.Radio(['True', 'False'], type="value", default='False', label='Fix Sampling\n (Fix the random seed)')
22
+ 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')
23
+ with gr.Column():
24
+ result = gr.Gallery(label='Output', show_label=False, elem_id="gallery").style(grid=2, height='auto')
25
+ ips = [input_img, type_in, color_back, prompt, neg_prompt, fix_sample, scale, con_strength, base_model]
26
+ run_button.click(fn=process, inputs=ips, outputs=[result])
27
+
28
+ return block
29
+