Fabrice-TIERCELIN commited on
Commit
745d524
·
verified ·
1 Parent(s): 275b1b0

Adapt information

Browse files
Files changed (1) hide show
  1. app.py +27 -15
app.py CHANGED
@@ -11,9 +11,14 @@ from PIL import Image, ImageFilter
11
 
12
  max_64_bit_int = 2**63 - 1
13
 
14
- device = "cuda" if torch.cuda.is_available() else "cpu"
15
- floatType = torch.float16 if torch.cuda.is_available() else torch.float32
16
- variant = "fp16" if torch.cuda.is_available() else None
 
 
 
 
 
17
 
18
  pipe = StableDiffusionXLInpaintPipeline.from_pretrained("diffusers/stable-diffusion-xl-1.0-inpainting-0.1", torch_dtype = floatType, variant = variant)
19
  pipe = pipe.to(device)
@@ -24,9 +29,7 @@ def update_seed(is_randomize_seed, seed):
24
  return seed
25
 
26
  def toggle_debug(is_debug_mode):
27
- if is_debug_mode:
28
- return [gr.update(visible = True)] * 3
29
- return [gr.update(visible = False)] * 3
30
 
31
  def noise_color(color, noise):
32
  return color + random.randint(- noise, noise)
@@ -45,6 +48,7 @@ def check(
45
  image_guidance_scale,
46
  strength,
47
  denoising_steps,
 
48
  seed,
49
  debug_mode,
50
  progress = gr.Progress()):
@@ -88,6 +92,7 @@ def uncrop(
88
  image_guidance_scale,
89
  strength,
90
  denoising_steps,
 
91
  seed,
92
  debug_mode,
93
  progress = gr.Progress()):
@@ -105,6 +110,7 @@ def uncrop(
105
  image_guidance_scale,
106
  strength,
107
  denoising_steps,
 
108
  seed,
109
  debug_mode
110
  )
@@ -259,7 +265,7 @@ def uncrop(
259
  minutes = minutes - (hours * 60)
260
  return [
261
  output_image,
262
- "Start again to get a different result. The new image is " + str(output_width) + " pixels large and " + str(output_height) + " pixels high, so an image of " + f'{output_width * output_height:,}' + " pixels. The image have been generated in " + str(hours) + " h, " + str(minutes) + " min, " + str(secondes) + " sec." + limitation,
263
  input_image,
264
  enlarged_image,
265
  mask_image
@@ -272,7 +278,7 @@ with gr.Blocks() as interface:
272
  <p style="text-align: center;">Enlarges the point of view of your image, freely, without account, without watermark, without installation, which can be downloaded</p>
273
  <br/>
274
  <br/>
275
- 🚀 Powered by <i>SDXL 1.0</i> artificial intellingence. For illustration purpose, not information purpose. The new content is not based on real information but imagination.
276
  <br/>
277
  <ul>
278
  <li>To change the <b>view angle</b> of your image, I recommend to use <i>Zero123</i>,</li>
@@ -284,7 +290,7 @@ with gr.Blocks() as interface:
284
  <li>To modify <b>anything else</b> on your image, I recommend to use <i>Instruct Pix2Pix</i>.</li>
285
  </ul>
286
  <br/>
287
- 🐌 Slow process... ~1 hour. Your computer must not enter into standby mode.<br/>You can duplicate this space on a free account, it works on CPU and should also run on CUDA.<br/>
288
  <a href='https://huggingface.co/spaces/Fabrice-TIERCELIN/Uncrop?duplicate=true'><img src='https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14'></a>
289
  <br/>
290
  ⚖️ You can use, modify and share the generated images but not for commercial uses.
@@ -313,10 +319,10 @@ with gr.Blocks() as interface:
313
  with gr.Column():
314
  dummy_4 = gr.Label(visible = False)
315
  with gr.Row():
316
- prompt = gr.Textbox(label = 'Prompt', info = "Describe the subject, the background and the style of image; 77 token limit", placeholder = 'Describe what you want to see in the entire image')
317
  with gr.Row():
318
  with gr.Accordion("Advanced options", open = False):
319
- negative_prompt = gr.Textbox(label = 'Negative prompt', placeholder = 'Describe what you do NOT want to see in the entire image', value = 'Border, frame, painting, scribbling, smear, noise, blur, watermark')
320
  smooth_border = gr.Slider(minimum = 0, maximum = 1024, value = 0, step = 2, label = "Smooth border", info = "lower=preserve original, higher=seamless")
321
  num_inference_steps = gr.Slider(minimum = 10, maximum = 100, value = 50, step = 1, label = "Number of inference steps", info = "lower=faster, higher=image quality")
322
  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")
@@ -328,7 +334,7 @@ with gr.Blocks() as interface:
328
  debug_mode = gr.Checkbox(label = "Debug mode", value = False, info = "Show intermediate results")
329
 
330
  with gr.Row():
331
- submit = gr.Button("Uncrop", variant = "primary")
332
 
333
  with gr.Row():
334
  uncropped_image = gr.Image(label = "Uncropped image")
@@ -364,6 +370,7 @@ with gr.Blocks() as interface:
364
  image_guidance_scale,
365
  strength,
366
  denoising_steps,
 
367
  seed,
368
  debug_mode
369
  ], outputs = [], queue = False,
@@ -381,6 +388,7 @@ with gr.Blocks() as interface:
381
  image_guidance_scale,
382
  strength,
383
  denoising_steps,
 
384
  seed,
385
  debug_mode
386
  ], outputs = [
@@ -407,6 +415,7 @@ with gr.Blocks() as interface:
407
  image_guidance_scale,
408
  strength,
409
  denoising_steps,
 
410
  seed,
411
  debug_mode
412
  ],
@@ -425,13 +434,14 @@ with gr.Blocks() as interface:
425
  1024,
426
  1024,
427
  "A woman, black hair, nowadays, in the street, ultrarealistic, realistic, photorealistic, 8k",
428
- "Border, frame, painting, drawing, cartoon, 3d, scribbling, smear, noise, blur, watermark",
429
  0,
430
  50,
431
  7,
432
  1.5,
433
  0.99,
434
  1000,
 
435
  42,
436
  False
437
  ],
@@ -442,13 +452,14 @@ with gr.Blocks() as interface:
442
  1024,
443
  1024,
444
  "A man, jumping in the air, outside, ultrarealistic, realistic, photorealistic, 8k",
445
- "Border, frame, painting, drawing, cartoon, 3d, scribbling, smear, noise, blur, watermark",
446
  0,
447
  50,
448
  7,
449
  1.5,
450
  0.99,
451
  1000,
 
452
  42,
453
  False
454
  ],
@@ -459,13 +470,14 @@ with gr.Blocks() as interface:
459
  0,
460
  512,
461
  "An old yellow car, in a town, ultrarealistic, realistic, photorealistic, 8k",
462
- "Border, frame, painting, drawing, cartoon, 3d, scribbling, smear, noise, blur, watermark",
463
  0,
464
  50,
465
  7,
466
  1.5,
467
  0.99,
468
  1000,
 
469
  42,
470
  False
471
  ],
 
11
 
12
  max_64_bit_int = 2**63 - 1
13
 
14
+ if torch.cuda.is_available():
15
+ device = "cuda"
16
+ floatType = torch.float16
17
+ variant = "fp16"
18
+ else:
19
+ device = "cpu"
20
+ floatType = torch.float32
21
+ variant = None
22
 
23
  pipe = StableDiffusionXLInpaintPipeline.from_pretrained("diffusers/stable-diffusion-xl-1.0-inpainting-0.1", torch_dtype = floatType, variant = variant)
24
  pipe = pipe.to(device)
 
29
  return seed
30
 
31
  def toggle_debug(is_debug_mode):
32
+ return [gr.update(visible = is_debug_mode)] * 3
 
 
33
 
34
  def noise_color(color, noise):
35
  return color + random.randint(- noise, noise)
 
48
  image_guidance_scale,
49
  strength,
50
  denoising_steps,
51
+ is_randomize_seed,
52
  seed,
53
  debug_mode,
54
  progress = gr.Progress()):
 
92
  image_guidance_scale,
93
  strength,
94
  denoising_steps,
95
+ is_randomize_seed,
96
  seed,
97
  debug_mode,
98
  progress = gr.Progress()):
 
110
  image_guidance_scale,
111
  strength,
112
  denoising_steps,
113
+ is_randomize_seed,
114
  seed,
115
  debug_mode
116
  )
 
265
  minutes = minutes - (hours * 60)
266
  return [
267
  output_image,
268
+ ("Start again to get a different result. " if is_randomize_seed else "") + "The new image is " + str(output_width) + " pixels large and " + str(output_height) + " pixels high, so an image of " + f'{output_width * output_height:,}' + " pixels. The image have been generated in " + str(hours) + " h, " + str(minutes) + " min, " + str(secondes) + " sec." + limitation,
269
  input_image,
270
  enlarged_image,
271
  mask_image
 
278
  <p style="text-align: center;">Enlarges the point of view of your image, freely, without account, without watermark, without installation, which can be downloaded</p>
279
  <br/>
280
  <br/>
281
+ Powered by <i>SDXL 1.0</i> artificial intellingence. For illustration purpose, not information purpose. The new content is not based on real information but imagination.
282
  <br/>
283
  <ul>
284
  <li>To change the <b>view angle</b> of your image, I recommend to use <i>Zero123</i>,</li>
 
290
  <li>To modify <b>anything else</b> on your image, I recommend to use <i>Instruct Pix2Pix</i>.</li>
291
  </ul>
292
  <br/>
293
+ 🐌 Slow process... ~1 hour. Your computer must <u>not</u> enter into standby mode.<br/>You can duplicate this space on a free account, it works on CPU and should also run on CUDA.<br/>
294
  <a href='https://huggingface.co/spaces/Fabrice-TIERCELIN/Uncrop?duplicate=true'><img src='https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14'></a>
295
  <br/>
296
  ⚖️ You can use, modify and share the generated images but not for commercial uses.
 
319
  with gr.Column():
320
  dummy_4 = gr.Label(visible = False)
321
  with gr.Row():
322
+ prompt = gr.Textbox(label = "Prompt", info = "Describe the subject, the background and the style of image; 77 token limit", placeholder = "Describe what you want to see in the entire image", lines = 2)
323
  with gr.Row():
324
  with gr.Accordion("Advanced options", open = False):
325
+ negative_prompt = gr.Textbox(label = "Negative prompt", placeholder = "Describe what you do NOT want to see in the entire image", value = 'Border, frame, painting, scribbling, smear, noise, blur, watermark')
326
  smooth_border = gr.Slider(minimum = 0, maximum = 1024, value = 0, step = 2, label = "Smooth border", info = "lower=preserve original, higher=seamless")
327
  num_inference_steps = gr.Slider(minimum = 10, maximum = 100, value = 50, step = 1, label = "Number of inference steps", info = "lower=faster, higher=image quality")
328
  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")
 
334
  debug_mode = gr.Checkbox(label = "Debug mode", value = False, info = "Show intermediate results")
335
 
336
  with gr.Row():
337
+ submit = gr.Button("🚀 Uncrop", variant = "primary")
338
 
339
  with gr.Row():
340
  uncropped_image = gr.Image(label = "Uncropped image")
 
370
  image_guidance_scale,
371
  strength,
372
  denoising_steps,
373
+ randomize_seed,
374
  seed,
375
  debug_mode
376
  ], outputs = [], queue = False,
 
388
  image_guidance_scale,
389
  strength,
390
  denoising_steps,
391
+ randomize_seed,
392
  seed,
393
  debug_mode
394
  ], outputs = [
 
415
  image_guidance_scale,
416
  strength,
417
  denoising_steps,
418
+ randomize_seed,
419
  seed,
420
  debug_mode
421
  ],
 
434
  1024,
435
  1024,
436
  "A woman, black hair, nowadays, in the street, ultrarealistic, realistic, photorealistic, 8k",
437
+ "Border, frame, painting, drawing, cartoon, anime, 3d, scribbling, smear, noise, blur, watermark",
438
  0,
439
  50,
440
  7,
441
  1.5,
442
  0.99,
443
  1000,
444
+ False,
445
  42,
446
  False
447
  ],
 
452
  1024,
453
  1024,
454
  "A man, jumping in the air, outside, ultrarealistic, realistic, photorealistic, 8k",
455
+ "Border, frame, painting, drawing, cartoon, anime, 3d, scribbling, smear, noise, blur, watermark",
456
  0,
457
  50,
458
  7,
459
  1.5,
460
  0.99,
461
  1000,
462
+ False,
463
  42,
464
  False
465
  ],
 
470
  0,
471
  512,
472
  "An old yellow car, in a town, ultrarealistic, realistic, photorealistic, 8k",
473
+ "Border, frame, painting, drawing, cartoon, anime, 3d, scribbling, smear, noise, blur, watermark",
474
  0,
475
  50,
476
  7,
477
  1.5,
478
  0.99,
479
  1000,
480
+ False,
481
  42,
482
  False
483
  ],