Fabrice-TIERCELIN commited on
Commit
17da47c
·
verified ·
1 Parent(s): 2132321

Handles HEIC

Browse files
Files changed (1) hide show
  1. app.py +23 -9
app.py CHANGED
@@ -1,10 +1,8 @@
1
  import gradio as gr
2
  import numpy as np
3
- import os
4
  import time
5
  import math
6
  import random
7
- import imageio
8
  import torch
9
  import spaces
10
 
@@ -13,6 +11,9 @@ from diffusers import (
13
  StableDiffusionControlNetPipeline,
14
  )
15
  from PIL import Image
 
 
 
16
 
17
  max_64_bit_int = np.iinfo(np.int32).max
18
 
@@ -177,10 +178,13 @@ with gr.Blocks() as interface:
177
  input_image = gr.Image(label = "Your image", sources = ["upload", "webcam", "clipboard"], type = "pil")
178
  prompt = gr.Textbox(label = "Prompt", info = "Instruct what to change in the image", placeholder = "Order the AI what to change in the image", lines = 2)
179
  with gr.Accordion("Advanced options", open = False):
180
- negative_prompt = gr.Textbox(label = "Negative prompt", placeholder = "Describe what you do NOT want to see in the image", value = "Watermark")
 
 
 
181
  denoising_steps = gr.Slider(minimum = 0, maximum = 1000, value = 0, step = 1, label = "Denoising", info = "lower=irrelevant result, higher=relevant result")
182
  num_inference_steps = gr.Slider(minimum = 10, maximum = 500, value = 20, step = 1, label = "Number of inference steps", info = "lower=faster, higher=image quality")
183
- guidance_scale = gr.Slider(minimum = 1, maximum = 13, value = 5, step = 0.1, label = "Classifier-Free Guidance Scale", info = "lower=image quality, higher=follow the prompt")
184
  image_guidance_scale = gr.Slider(minimum = 1, value = 1.5, step = 0.1, label = "Image Guidance Scale", info = "lower=image quality, higher=follow the image")
185
  randomize_seed = gr.Checkbox(label = "\U0001F3B2 Randomize seed", value = True, info = "If checked, result is always different")
186
  seed = gr.Slider(minimum = 0, maximum = max_64_bit_int, step = 1, randomize = True, label = "Seed")
@@ -242,7 +246,9 @@ with gr.Blocks() as interface:
242
  [
243
  "./Examples/Example1.webp",
244
  "What if it's snowing?",
245
- "Watermark",
 
 
246
  1,
247
  20,
248
  5,
@@ -253,7 +259,9 @@ with gr.Blocks() as interface:
253
  [
254
  "./Examples/Example2.png",
255
  "What if this woman had brown hair?",
256
- "Watermark",
 
 
257
  1,
258
  20,
259
  5,
@@ -264,7 +272,9 @@ with gr.Blocks() as interface:
264
  [
265
  "./Examples/Example3.jpeg",
266
  "Replace the house by a windmill",
267
- "Watermark",
 
 
268
  1,
269
  20,
270
  5,
@@ -275,7 +285,9 @@ with gr.Blocks() as interface:
275
  [
276
  "./Examples/Example4.gif",
277
  "What if the camera was in opposite side?",
278
- "Watermark",
 
 
279
  1,
280
  20,
281
  5,
@@ -286,7 +298,9 @@ with gr.Blocks() as interface:
286
  [
287
  "./Examples/Example5.bmp",
288
  "Turn him into cyborg",
289
- "Watermark",
 
 
290
  1,
291
  20,
292
  5,
 
1
  import gradio as gr
2
  import numpy as np
 
3
  import time
4
  import math
5
  import random
 
6
  import torch
7
  import spaces
8
 
 
11
  StableDiffusionControlNetPipeline,
12
  )
13
  from PIL import Image
14
+ from pillow_heif import register_heif_opener
15
+
16
+ register_heif_opener()
17
 
18
  max_64_bit_int = np.iinfo(np.int32).max
19
 
 
178
  input_image = gr.Image(label = "Your image", sources = ["upload", "webcam", "clipboard"], type = "pil")
179
  prompt = gr.Textbox(label = "Prompt", info = "Instruct what to change in the image", placeholder = "Order the AI what to change in the image", lines = 2)
180
  with gr.Accordion("Advanced options", open = False):
181
+ negative_prompt = gr.Textbox(label = "Negative prompt", placeholder = "Describe what you do NOT want to see in the image", value = ''
182
+ 'blurring, aliasing, unsharp, weird textures, ugly, dirty, messy, '
183
+ 'worst quality, low quality, frames, watermark, signature, jpeg artifacts, '
184
+ 'deformed, lowres, over-smooth')
185
  denoising_steps = gr.Slider(minimum = 0, maximum = 1000, value = 0, step = 1, label = "Denoising", info = "lower=irrelevant result, higher=relevant result")
186
  num_inference_steps = gr.Slider(minimum = 10, maximum = 500, value = 20, step = 1, label = "Number of inference steps", info = "lower=faster, higher=image quality")
187
+ guidance_scale = gr.Slider(minimum = 1, maximum = 13, value = 5, step = 0.1, label = "Guidance Scale", info = "lower=image quality, higher=follow the prompt")
188
  image_guidance_scale = gr.Slider(minimum = 1, value = 1.5, step = 0.1, label = "Image Guidance Scale", info = "lower=image quality, higher=follow the image")
189
  randomize_seed = gr.Checkbox(label = "\U0001F3B2 Randomize seed", value = True, info = "If checked, result is always different")
190
  seed = gr.Slider(minimum = 0, maximum = max_64_bit_int, step = 1, randomize = True, label = "Seed")
 
246
  [
247
  "./Examples/Example1.webp",
248
  "What if it's snowing?",
249
+ "blurring, aliasing, unsharp, weird textures, ugly, dirty, messy, "
250
+ "worst quality, low quality, frames, watermark, signature, jpeg artifacts, "
251
+ "deformed, lowres, over-smooth",
252
  1,
253
  20,
254
  5,
 
259
  [
260
  "./Examples/Example2.png",
261
  "What if this woman had brown hair?",
262
+ "blurring, aliasing, unsharp, weird textures, ugly, dirty, messy, "
263
+ "worst quality, low quality, frames, watermark, signature, jpeg artifacts, "
264
+ "deformed, lowres, over-smooth",
265
  1,
266
  20,
267
  5,
 
272
  [
273
  "./Examples/Example3.jpeg",
274
  "Replace the house by a windmill",
275
+ "blurring, aliasing, unsharp, weird textures, ugly, dirty, messy, "
276
+ "worst quality, low quality, frames, watermark, signature, jpeg artifacts, "
277
+ "deformed, lowres, over-smooth",
278
  1,
279
  20,
280
  5,
 
285
  [
286
  "./Examples/Example4.gif",
287
  "What if the camera was in opposite side?",
288
+ "blurring, aliasing, unsharp, weird textures, ugly, dirty, messy, "
289
+ "worst quality, low quality, frames, watermark, signature, jpeg artifacts, "
290
+ "deformed, lowres, over-smooth",
291
  1,
292
  20,
293
  5,
 
298
  [
299
  "./Examples/Example5.bmp",
300
  "Turn him into cyborg",
301
+ "blurring, aliasing, unsharp, weird textures, ugly, dirty, messy, "
302
+ "worst quality, low quality, frames, watermark, signature, jpeg artifacts, "
303
+ "deformed, lowres, over-smooth",
304
  1,
305
  20,
306
  5,