Fabrice-TIERCELIN commited on
Commit
427f299
1 Parent(s): daae8ba
Files changed (1) hide show
  1. app.py +51 -15
app.py CHANGED
@@ -22,11 +22,11 @@ def check(
22
  prompt,
23
  uploaded_mask,
24
  negative_prompt,
25
- denoising_steps,
26
  num_inference_steps,
27
  guidance_scale,
28
  image_guidance_scale,
29
  strength,
 
30
  randomize_seed,
31
  seed,
32
  debug_mode,
@@ -43,11 +43,11 @@ def inpaint(
43
  prompt,
44
  uploaded_mask,
45
  negative_prompt,
46
- denoising_steps,
47
  num_inference_steps,
48
  guidance_scale,
49
  image_guidance_scale,
50
  strength,
 
51
  randomize_seed,
52
  seed,
53
  debug_mode,
@@ -58,11 +58,11 @@ def inpaint(
58
  prompt,
59
  uploaded_mask,
60
  negative_prompt,
61
- denoising_steps,
62
  num_inference_steps,
63
  guidance_scale,
64
  image_guidance_scale,
65
  strength,
 
66
  randomize_seed,
67
  seed,
68
  debug_mode
@@ -73,9 +73,6 @@ def inpaint(
73
  if negative_prompt is None:
74
  negative_prompt = ""
75
 
76
- if denoising_steps is None:
77
- denoising_steps = 1000
78
-
79
  if num_inference_steps is None:
80
  num_inference_steps = 25
81
 
@@ -88,6 +85,9 @@ def inpaint(
88
  if strength is None:
89
  strength = 0.99
90
 
 
 
 
91
  if randomize_seed:
92
  seed = random.randint(0, max_64_bit_int)
93
 
@@ -210,11 +210,11 @@ with gr.Blocks() as interface:
210
  uploaded_mask = gr.Image(label = "Already made mask (black pixels will be preserved, white pixels will be redrawn)", source = "upload", type = "pil")
211
  with gr.Accordion("Advanced options", open = False):
212
  negative_prompt = gr.Textbox(label = "Negative prompt", placeholder = "Describe what you do NOT want to see in the entire image", value = "Ugly, malformed, noise, blur, watermark")
213
- denoising_steps = gr.Slider(minimum = 0, maximum = 1000, value = 1000, step = 1, label = "Denoising", info = "lower=irrelevant result, higher=relevant result")
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.Number(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
  randomize_seed = gr.Checkbox(label = "\U0001F3B2 Randomize seed (not working, always checked)", value = True, info = "If checked, result is always different")
219
  seed = gr.Slider(minimum = 0, maximum = max_64_bit_int, step = 1, randomize = True, label = "Seed (if not randomized)")
220
  debug_mode = gr.Checkbox(label = "Debug mode", value = False, info = "Show intermediate results")
@@ -234,11 +234,11 @@ with gr.Blocks() as interface:
234
  prompt,
235
  uploaded_mask,
236
  negative_prompt,
237
- denoising_steps,
238
  num_inference_steps,
239
  guidance_scale,
240
  image_guidance_scale,
241
  strength,
 
242
  randomize_seed,
243
  seed,
244
  debug_mode
@@ -247,11 +247,11 @@ with gr.Blocks() as interface:
247
  prompt,
248
  uploaded_mask,
249
  negative_prompt,
250
- denoising_steps,
251
  num_inference_steps,
252
  guidance_scale,
253
  image_guidance_scale,
254
  strength,
 
255
  randomize_seed,
256
  seed,
257
  debug_mode
@@ -268,11 +268,11 @@ with gr.Blocks() as interface:
268
  prompt,
269
  uploaded_mask,
270
  negative_prompt,
271
- denoising_steps,
272
  num_inference_steps,
273
  guidance_scale,
274
  image_guidance_scale,
275
  strength,
 
276
  randomize_seed,
277
  seed,
278
  debug_mode
@@ -289,11 +289,11 @@ with gr.Blocks() as interface:
289
  "A deer, in a forest landscape, ultrarealistic, realistic, photorealistic, 8k",
290
  "./Examples/Mask1.webp",
291
  "Painting, drawing, cartoon, ugly, malformed, noise, blur, watermark",
292
- 1000,
293
  25,
294
  7,
295
  1.1,
296
  0.99,
 
297
  True,
298
  42,
299
  False
@@ -303,11 +303,11 @@ with gr.Blocks() as interface:
303
  "An angry old woman, ultrarealistic, realistic, photorealistic, 8k",
304
  "./Examples/Mask3.gif",
305
  "Painting, drawing, cartoon, ugly, malformed, noise, blur, watermark",
306
- 1000,
307
  25,
308
  7,
309
  1.5,
310
  0.99,
 
311
  True,
312
  42,
313
  False
@@ -317,11 +317,11 @@ with gr.Blocks() as interface:
317
  "A laptop, ultrarealistic, realistic, photorealistic, 8k",
318
  "./Examples/Mask4.bmp",
319
  "Painting, drawing, cartoon, ugly, malformed, noise, blur, watermark",
320
- 1000,
321
  25,
322
  7,
323
  1.1,
324
  0.99,
 
325
  True,
326
  42,
327
  False
@@ -331,11 +331,11 @@ with gr.Blocks() as interface:
331
  "A sand castle, ultrarealistic, realistic, photorealistic, 8k",
332
  "./Examples/Mask5.png",
333
  "Painting, drawing, cartoon, ugly, malformed, noise, blur, watermark",
334
- 1000,
335
  50,
336
  7,
337
  1.5,
338
  0.5,
 
339
  True,
340
  42,
341
  False
@@ -345,11 +345,11 @@ with gr.Blocks() as interface:
345
  "A cat, ultrarealistic, realistic, photorealistic, 8k",
346
  "./Examples/Mask2.png",
347
  "Painting, drawing, cartoon, ugly, malformed, noise, blur, watermark",
348
- 1000,
349
  25,
350
  7,
351
  1.1,
352
  0.99,
 
353
  True,
354
  42,
355
  False
@@ -357,5 +357,41 @@ with gr.Blocks() as interface:
357
  ],
358
  cache_examples = False,
359
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
 
361
  interface.queue().launch()
 
22
  prompt,
23
  uploaded_mask,
24
  negative_prompt,
 
25
  num_inference_steps,
26
  guidance_scale,
27
  image_guidance_scale,
28
  strength,
29
+ denoising_steps,
30
  randomize_seed,
31
  seed,
32
  debug_mode,
 
43
  prompt,
44
  uploaded_mask,
45
  negative_prompt,
 
46
  num_inference_steps,
47
  guidance_scale,
48
  image_guidance_scale,
49
  strength,
50
+ denoising_steps,
51
  randomize_seed,
52
  seed,
53
  debug_mode,
 
58
  prompt,
59
  uploaded_mask,
60
  negative_prompt,
 
61
  num_inference_steps,
62
  guidance_scale,
63
  image_guidance_scale,
64
  strength,
65
+ denoising_steps,
66
  randomize_seed,
67
  seed,
68
  debug_mode
 
73
  if negative_prompt is None:
74
  negative_prompt = ""
75
 
 
 
 
76
  if num_inference_steps is None:
77
  num_inference_steps = 25
78
 
 
85
  if strength is None:
86
  strength = 0.99
87
 
88
+ if denoising_steps is None:
89
+ denoising_steps = 1000
90
+
91
  if randomize_seed:
92
  seed = random.randint(0, max_64_bit_int)
93
 
 
210
  uploaded_mask = gr.Image(label = "Already made mask (black pixels will be preserved, white pixels will be redrawn)", source = "upload", type = "pil")
211
  with gr.Accordion("Advanced options", open = False):
212
  negative_prompt = gr.Textbox(label = "Negative prompt", placeholder = "Describe what you do NOT want to see in the entire image", value = "Ugly, malformed, noise, blur, watermark")
 
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.Number(value = 0.99, minimum = 0.01, maximum = 1.0, step = 0.01, label = "Strength", info = "lower=follow the original area, higher=redraw from scratch")
217
+ denoising_steps = gr.Slider(minimum = 0, maximum = 1000, value = 1000, step = 1, label = "Denoising", info = "lower=irrelevant result, higher=relevant result")
218
  randomize_seed = gr.Checkbox(label = "\U0001F3B2 Randomize seed (not working, always checked)", value = True, info = "If checked, result is always different")
219
  seed = gr.Slider(minimum = 0, maximum = max_64_bit_int, step = 1, randomize = True, label = "Seed (if not randomized)")
220
  debug_mode = gr.Checkbox(label = "Debug mode", value = False, info = "Show intermediate results")
 
234
  prompt,
235
  uploaded_mask,
236
  negative_prompt,
 
237
  num_inference_steps,
238
  guidance_scale,
239
  image_guidance_scale,
240
  strength,
241
+ denoising_steps,
242
  randomize_seed,
243
  seed,
244
  debug_mode
 
247
  prompt,
248
  uploaded_mask,
249
  negative_prompt,
 
250
  num_inference_steps,
251
  guidance_scale,
252
  image_guidance_scale,
253
  strength,
254
+ denoising_steps,
255
  randomize_seed,
256
  seed,
257
  debug_mode
 
268
  prompt,
269
  uploaded_mask,
270
  negative_prompt,
 
271
  num_inference_steps,
272
  guidance_scale,
273
  image_guidance_scale,
274
  strength,
275
+ denoising_steps,
276
  randomize_seed,
277
  seed,
278
  debug_mode
 
289
  "A deer, in a forest landscape, ultrarealistic, realistic, photorealistic, 8k",
290
  "./Examples/Mask1.webp",
291
  "Painting, drawing, cartoon, ugly, malformed, noise, blur, watermark",
 
292
  25,
293
  7,
294
  1.1,
295
  0.99,
296
+ 1000,
297
  True,
298
  42,
299
  False
 
303
  "An angry old woman, ultrarealistic, realistic, photorealistic, 8k",
304
  "./Examples/Mask3.gif",
305
  "Painting, drawing, cartoon, ugly, malformed, noise, blur, watermark",
 
306
  25,
307
  7,
308
  1.5,
309
  0.99,
310
+ 1000,
311
  True,
312
  42,
313
  False
 
317
  "A laptop, ultrarealistic, realistic, photorealistic, 8k",
318
  "./Examples/Mask4.bmp",
319
  "Painting, drawing, cartoon, ugly, malformed, noise, blur, watermark",
 
320
  25,
321
  7,
322
  1.1,
323
  0.99,
324
+ 1000,
325
  True,
326
  42,
327
  False
 
331
  "A sand castle, ultrarealistic, realistic, photorealistic, 8k",
332
  "./Examples/Mask5.png",
333
  "Painting, drawing, cartoon, ugly, malformed, noise, blur, watermark",
 
334
  50,
335
  7,
336
  1.5,
337
  0.5,
338
+ 1000,
339
  True,
340
  42,
341
  False
 
345
  "A cat, ultrarealistic, realistic, photorealistic, 8k",
346
  "./Examples/Mask2.png",
347
  "Painting, drawing, cartoon, ugly, malformed, noise, blur, watermark",
 
348
  25,
349
  7,
350
  1.1,
351
  0.99,
352
+ 1000,
353
  True,
354
  42,
355
  False
 
357
  ],
358
  cache_examples = False,
359
  )
360
+
361
+ gr.Markdown(
362
+ """
363
+ ### How to prompt your image
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
+ ```
367
+ A Vietnamese woman, red clothes, walking, smilling, in the street, a car on the left, in a modern city, photorealistic, 8k
368
+ ```
369
+
370
+ You can use round brackets to increase the importance of a part:
371
+ ```
372
+ A Vietnamese woman, (red clothes), walking, smilling, in the street, a car on the left, in a modern city, photorealistic, 8k
373
+ ```
374
+
375
+ You can use several levels of round brackets to even more increase the importance of a part:
376
+ ```
377
+ A Vietnamese woman, ((red clothes)), (walking), smilling, in the street, a car on the left, in a modern city, photorealistic, 8k
378
+ ```
379
+
380
+ You can use number instead of several round brackets:
381
+ ```
382
+ A Vietnamese woman, (red clothes:1.5), (walking), smilling, in the street, a car on the left, in a modern city, photorealistic, 8k
383
+ ```
384
+
385
+ You can do the same thing with square brackets to decrease the importance of a part:
386
+ ```
387
+ A [Vietnamese] woman, (red clothes:1.5), (walking), smilling, in the street, a car on the left, in a modern city, photorealistic, 8k
388
+ ```
389
+
390
+ To easily read your negative prompt, organize it the same way as your prompt (not important for the AI):
391
+ ```
392
+ man, boy, hat, running, tree, bicycle, forest, drawing, painting, cartoon, 3d, monochrome, blurry, noisy, bokeh
393
+ ```
394
+ """
395
+ )
396
 
397
  interface.queue().launch()