Skip to content

Commit efbd3dc

Browse files
committed
[WEB] Fix debug option and add random seed generation
Signed-Off-by: Gaurav Shukla
1 parent a0d0eaa commit efbd3dc

File tree

1 file changed

+41
-38
lines changed

1 file changed

+41
-38
lines changed

web/index.py

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@
8989
step=0.1,
9090
label="Guidance Scale",
9191
)
92+
precision = gr.Radio(
93+
label="Precision",
94+
value="fp16",
95+
choices=["fp16", "fp32"],
96+
)
9297
# Hidden Items
9398
height = gr.Slider(
9499
384,
@@ -108,22 +113,36 @@
108113
interactive=False,
109114
visible=False,
110115
)
111-
with gr.Row():
112-
precision = gr.Radio(
113-
label="Precision",
114-
value="fp16",
115-
choices=["fp16", "fp32"],
116+
scheduler = gr.Radio(
117+
label="Scheduler",
118+
value="DPM",
119+
choices=["PNDM", "LMS", "DDIM", "DPM"],
120+
visible=False,
116121
)
117-
uint32_info = iinfo(np.uint32)
118-
rand_seed = randint(uint32_info.min, uint32_info.max)
119-
seed = gr.Number(
120-
value=rand_seed,
121-
label="Seed",
122+
with gr.Row(equal_height=True):
123+
device = gr.Radio(
124+
label="Device",
125+
value="vulkan",
126+
choices=["cuda", "vulkan"],
127+
interactive=False,
122128
)
123-
with gr.Row():
129+
with gr.Group():
130+
uint32_info = iinfo(np.uint32)
131+
rand_seed = randint(uint32_info.min, uint32_info.max)
132+
random_seed = gr.Button("Random seed").style(
133+
full_width=True
134+
)
135+
seed = gr.Number(value=rand_seed, show_label=False)
136+
random_seed.click(
137+
lambda: randint(uint32_info.min, uint32_info.max),
138+
inputs=[],
139+
outputs=[seed],
140+
)
124141
cache = gr.Checkbox(label="Cache", value=True)
125-
debug = gr.Checkbox(label="DEBUG", value=False)
126-
save_img = gr.Checkbox(label="Save Image", value=False)
142+
debug = gr.Checkbox(label="DEBUG", value=True)
143+
save_img = gr.Checkbox(
144+
label="Save", value=False, visible=False
145+
)
127146
# Hidden Items.
128147
live_preview = gr.Checkbox(
129148
label="Live Preview",
@@ -137,20 +156,6 @@
137156
interactive=False,
138157
visible=False,
139158
)
140-
scheduler = gr.Radio(
141-
label="Scheduler",
142-
value="DPM",
143-
choices=["PNDM", "LMS", "DDIM", "DPM"],
144-
interactive=False,
145-
visible=False,
146-
)
147-
device = gr.Radio(
148-
label="Device",
149-
value="vulkan",
150-
choices=["cpu", "cuda", "vulkan"],
151-
interactive=False,
152-
visible=False,
153-
)
154159
iters_count = gr.Slider(
155160
1,
156161
24,
@@ -175,18 +180,16 @@
175180
)
176181
stable_diffusion = gr.Button("Generate Image")
177182
with gr.Column(scale=1, min_width=600):
178-
with gr.Row():
179-
generated_img = gr.Image(
180-
type="pil", elem_id="img_result", interactive=False
181-
).style(height=768)
182-
std_output = gr.Textbox(
183-
label="Std Output",
184-
value="Nothing.",
185-
lines=5,
186-
visible=False,
187-
)
183+
generated_img = gr.Image(type="pil", interactive=False).style(
184+
height=768
185+
)
186+
std_output = gr.Textbox(
187+
label="Std Output",
188+
value="Loading...",
189+
lines=5,
190+
)
188191
debug.change(
189-
lambda x: gr.Textbox.update(visible=x),
192+
lambda x: gr.update(visible=x),
190193
inputs=[debug],
191194
outputs=[std_output],
192195
)

0 commit comments

Comments
 (0)