Spaces:
Running
Running
Commit
•
c17ed86
1
Parent(s):
427f299
Update seed
Browse files
app.py
CHANGED
@@ -27,7 +27,6 @@ def check(
|
|
27 |
image_guidance_scale,
|
28 |
strength,
|
29 |
denoising_steps,
|
30 |
-
randomize_seed,
|
31 |
seed,
|
32 |
debug_mode,
|
33 |
progress = gr.Progress()
|
@@ -48,7 +47,6 @@ def inpaint(
|
|
48 |
image_guidance_scale,
|
49 |
strength,
|
50 |
denoising_steps,
|
51 |
-
randomize_seed,
|
52 |
seed,
|
53 |
debug_mode,
|
54 |
progress = gr.Progress()
|
@@ -63,7 +61,6 @@ def inpaint(
|
|
63 |
image_guidance_scale,
|
64 |
strength,
|
65 |
denoising_steps,
|
66 |
-
randomize_seed,
|
67 |
seed,
|
68 |
debug_mode
|
69 |
)
|
@@ -88,7 +85,7 @@ def inpaint(
|
|
88 |
if denoising_steps is None:
|
89 |
denoising_steps = 1000
|
90 |
|
91 |
-
if
|
92 |
seed = random.randint(0, max_64_bit_int)
|
93 |
|
94 |
random.seed(seed)
|
@@ -171,11 +168,15 @@ def inpaint(
|
|
171 |
mask_image
|
172 |
]
|
173 |
|
|
|
|
|
|
|
|
|
|
|
174 |
def toggle_debug(is_debug_mode):
|
175 |
if is_debug_mode:
|
176 |
return [gr.update(visible = True)] * 2
|
177 |
-
|
178 |
-
return [gr.update(visible = False)] * 2
|
179 |
|
180 |
with gr.Blocks() as interface:
|
181 |
gr.Markdown(
|
@@ -213,10 +214,10 @@ with gr.Blocks() as interface:
|
|
213 |
num_inference_steps = gr.Slider(minimum = 10, maximum = 100, value = 25, step = 1, label = "Number of inference steps", info = "lower=faster, higher=image quality")
|
214 |
guidance_scale = gr.Slider(minimum = 1, maximum = 13, value = 7, step = 0.1, label = "Classifier-Free Guidance Scale", info = "lower=image quality, higher=follow the prompt")
|
215 |
image_guidance_scale = gr.Slider(minimum = 1, value = 1.1, step = 0.1, label = "Image Guidance Scale", info = "lower=image quality, higher=follow the image")
|
216 |
-
strength = gr.
|
217 |
-
denoising_steps = gr.
|
218 |
-
randomize_seed = gr.Checkbox(label = "\U0001F3B2 Randomize seed
|
219 |
-
seed = gr.Slider(minimum = 0, maximum = max_64_bit_int, step = 1, randomize = True, label = "Seed
|
220 |
debug_mode = gr.Checkbox(label = "Debug mode", value = False, info = "Show intermediate results")
|
221 |
|
222 |
submit = gr.Button("Inpaint", variant = "primary")
|
@@ -226,7 +227,11 @@ with gr.Blocks() as interface:
|
|
226 |
original_image = gr.Image(label = "Original image", visible = False)
|
227 |
mask_image = gr.Image(label = "Mask image", visible = False)
|
228 |
|
229 |
-
submit.click(
|
|
|
|
|
|
|
|
|
230 |
original_image,
|
231 |
mask_image
|
232 |
], queue = False, show_progress = False).then(check, inputs = [
|
@@ -239,7 +244,6 @@ with gr.Blocks() as interface:
|
|
239 |
image_guidance_scale,
|
240 |
strength,
|
241 |
denoising_steps,
|
242 |
-
randomize_seed,
|
243 |
seed,
|
244 |
debug_mode
|
245 |
], outputs = [], queue = False, show_progress = False).success(inpaint, inputs = [
|
@@ -252,7 +256,6 @@ with gr.Blocks() as interface:
|
|
252 |
image_guidance_scale,
|
253 |
strength,
|
254 |
denoising_steps,
|
255 |
-
randomize_seed,
|
256 |
seed,
|
257 |
debug_mode
|
258 |
], outputs = [
|
@@ -288,7 +291,7 @@ with gr.Blocks() as interface:
|
|
288 |
"./Examples/Example1.png",
|
289 |
"A deer, in a forest landscape, ultrarealistic, realistic, photorealistic, 8k",
|
290 |
"./Examples/Mask1.webp",
|
291 |
-
"
|
292 |
25,
|
293 |
7,
|
294 |
1.1,
|
@@ -302,7 +305,7 @@ with gr.Blocks() as interface:
|
|
302 |
"./Examples/Example3.jpg",
|
303 |
"An angry old woman, ultrarealistic, realistic, photorealistic, 8k",
|
304 |
"./Examples/Mask3.gif",
|
305 |
-
"
|
306 |
25,
|
307 |
7,
|
308 |
1.5,
|
@@ -316,7 +319,7 @@ with gr.Blocks() as interface:
|
|
316 |
"./Examples/Example4.gif",
|
317 |
"A laptop, ultrarealistic, realistic, photorealistic, 8k",
|
318 |
"./Examples/Mask4.bmp",
|
319 |
-
"
|
320 |
25,
|
321 |
7,
|
322 |
1.1,
|
@@ -330,7 +333,7 @@ with gr.Blocks() as interface:
|
|
330 |
"./Examples/Example5.bmp",
|
331 |
"A sand castle, ultrarealistic, realistic, photorealistic, 8k",
|
332 |
"./Examples/Mask5.png",
|
333 |
-
"
|
334 |
50,
|
335 |
7,
|
336 |
1.5,
|
@@ -344,7 +347,7 @@ with gr.Blocks() as interface:
|
|
344 |
"./Examples/Example2.webp",
|
345 |
"A cat, ultrarealistic, realistic, photorealistic, 8k",
|
346 |
"./Examples/Mask2.png",
|
347 |
-
"
|
348 |
25,
|
349 |
7,
|
350 |
1.1,
|
@@ -360,7 +363,7 @@ with gr.Blocks() as interface:
|
|
360 |
|
361 |
gr.Markdown(
|
362 |
"""
|
363 |
-
|
364 |
|
365 |
To easily read your prompt, start with the subject, then describ the pose or action, then secondary elements, then the background, then the graphical style, then the image quality:
|
366 |
```
|
|
|
27 |
image_guidance_scale,
|
28 |
strength,
|
29 |
denoising_steps,
|
|
|
30 |
seed,
|
31 |
debug_mode,
|
32 |
progress = gr.Progress()
|
|
|
47 |
image_guidance_scale,
|
48 |
strength,
|
49 |
denoising_steps,
|
|
|
50 |
seed,
|
51 |
debug_mode,
|
52 |
progress = gr.Progress()
|
|
|
61 |
image_guidance_scale,
|
62 |
strength,
|
63 |
denoising_steps,
|
|
|
64 |
seed,
|
65 |
debug_mode
|
66 |
)
|
|
|
85 |
if denoising_steps is None:
|
86 |
denoising_steps = 1000
|
87 |
|
88 |
+
if seed is None:
|
89 |
seed = random.randint(0, max_64_bit_int)
|
90 |
|
91 |
random.seed(seed)
|
|
|
168 |
mask_image
|
169 |
]
|
170 |
|
171 |
+
def update_seed(is_randomize_seed, seed):
|
172 |
+
if is_randomize_seed:
|
173 |
+
return random.randint(0, max_64_bit_int)
|
174 |
+
return seed
|
175 |
+
|
176 |
def toggle_debug(is_debug_mode):
|
177 |
if is_debug_mode:
|
178 |
return [gr.update(visible = True)] * 2
|
179 |
+
return [gr.update(visible = False)] * 2
|
|
|
180 |
|
181 |
with gr.Blocks() as interface:
|
182 |
gr.Markdown(
|
|
|
214 |
num_inference_steps = gr.Slider(minimum = 10, maximum = 100, value = 25, step = 1, label = "Number of inference steps", info = "lower=faster, higher=image quality")
|
215 |
guidance_scale = gr.Slider(minimum = 1, maximum = 13, value = 7, step = 0.1, label = "Classifier-Free Guidance Scale", info = "lower=image quality, higher=follow the prompt")
|
216 |
image_guidance_scale = gr.Slider(minimum = 1, value = 1.1, step = 0.1, label = "Image Guidance Scale", info = "lower=image quality, higher=follow the image")
|
217 |
+
strength = gr.Slider(value = 0.99, minimum = 0.01, maximum = 1.0, step = 0.01, label = "Strength", info = "lower=follow the original area, higher=redraw from scratch")
|
218 |
+
denoising_steps = gr.Number(minimum = 0, value = 1000, step = 1, label = "Denoising", info = "lower=irrelevant result, higher=relevant result")
|
219 |
+
randomize_seed = gr.Checkbox(label = "\U0001F3B2 Randomize seed", value = True, info = "If checked, result is always different")
|
220 |
+
seed = gr.Slider(minimum = 0, maximum = max_64_bit_int, step = 1, randomize = True, label = "Seed")
|
221 |
debug_mode = gr.Checkbox(label = "Debug mode", value = False, info = "Show intermediate results")
|
222 |
|
223 |
submit = gr.Button("Inpaint", variant = "primary")
|
|
|
227 |
original_image = gr.Image(label = "Original image", visible = False)
|
228 |
mask_image = gr.Image(label = "Mask image", visible = False)
|
229 |
|
230 |
+
submit.click(update_seed, inputs = [
|
231 |
+
randomize_seed, seed
|
232 |
+
], outputs = [
|
233 |
+
seed
|
234 |
+
], queue = False, show_progress = False).then(toggle_debug, debug_mode, [
|
235 |
original_image,
|
236 |
mask_image
|
237 |
], queue = False, show_progress = False).then(check, inputs = [
|
|
|
244 |
image_guidance_scale,
|
245 |
strength,
|
246 |
denoising_steps,
|
|
|
247 |
seed,
|
248 |
debug_mode
|
249 |
], outputs = [], queue = False, show_progress = False).success(inpaint, inputs = [
|
|
|
256 |
image_guidance_scale,
|
257 |
strength,
|
258 |
denoising_steps,
|
|
|
259 |
seed,
|
260 |
debug_mode
|
261 |
], outputs = [
|
|
|
291 |
"./Examples/Example1.png",
|
292 |
"A deer, in a forest landscape, ultrarealistic, realistic, photorealistic, 8k",
|
293 |
"./Examples/Mask1.webp",
|
294 |
+
"Ugly, malformed, painting, drawing, cartoon, 3d, noise, blur, watermark",
|
295 |
25,
|
296 |
7,
|
297 |
1.1,
|
|
|
305 |
"./Examples/Example3.jpg",
|
306 |
"An angry old woman, ultrarealistic, realistic, photorealistic, 8k",
|
307 |
"./Examples/Mask3.gif",
|
308 |
+
"Ugly, malformed, painting, drawing, cartoon, 3d, noise, blur, watermark",
|
309 |
25,
|
310 |
7,
|
311 |
1.5,
|
|
|
319 |
"./Examples/Example4.gif",
|
320 |
"A laptop, ultrarealistic, realistic, photorealistic, 8k",
|
321 |
"./Examples/Mask4.bmp",
|
322 |
+
"Ugly, malformed, painting, drawing, cartoon, 3d, noise, blur, watermark",
|
323 |
25,
|
324 |
7,
|
325 |
1.1,
|
|
|
333 |
"./Examples/Example5.bmp",
|
334 |
"A sand castle, ultrarealistic, realistic, photorealistic, 8k",
|
335 |
"./Examples/Mask5.png",
|
336 |
+
"Ugly, malformed, painting, drawing, cartoon, 3d, noise, blur, watermark",
|
337 |
50,
|
338 |
7,
|
339 |
1.5,
|
|
|
347 |
"./Examples/Example2.webp",
|
348 |
"A cat, ultrarealistic, realistic, photorealistic, 8k",
|
349 |
"./Examples/Mask2.png",
|
350 |
+
"Ugly, malformed, painting, drawing, cartoon, 3d, noise, blur, watermark",
|
351 |
25,
|
352 |
7,
|
353 |
1.1,
|
|
|
363 |
|
364 |
gr.Markdown(
|
365 |
"""
|
366 |
+
## How to prompt your image
|
367 |
|
368 |
To easily read your prompt, start with the subject, then describ the pose or action, then secondary elements, then the background, then the graphical style, then the image quality:
|
369 |
```
|