krrishD commited on
Commit
1635e3d
1 Parent(s): 64406bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -15
app.py CHANGED
@@ -18,18 +18,7 @@ from io import BytesIO
18
  import os
19
  from PIL import Image
20
  import face_recognition
21
- import whatimage
22
- import pyheif
23
-
24
- def decodeImage(bytesIo, filename):
25
- fmt = whatimage.identify_image(bytesIo)
26
- print(fmt)
27
- if fmt in ['heic', 'avif']:
28
- i = pyheif.read_heif(bytesIo)
29
- pi = Image.frombytes(
30
- mode=i.mode, size=i.size, data=i.data)
31
- print(pi)
32
- pi.save(filename, format="jpeg")
33
 
34
  def inpaint(p, init_image, mask_image=None, strength=0.75, guidance_scale=7.5, generator=None, num_samples=1, n_iter=1):
35
  buffered_init_img = BytesIO()
@@ -103,9 +92,7 @@ def preprocess_mask(mask):
103
  # output the sampled images
104
  def main(user_image):
105
  # accept the image as input
106
- with open(user_image.name, 'rb') as f:
107
- data = f.read()
108
- decodeImage(data, user_image.name)
109
  init_image = PIL.Image.open(user_image).convert("RGB")
110
  # # resize the image to be (512, 512)
111
  newsize = (512, 512)
 
18
  import os
19
  from PIL import Image
20
  import face_recognition
21
+ import pillow_heif
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  def inpaint(p, init_image, mask_image=None, strength=0.75, guidance_scale=7.5, generator=None, num_samples=1, n_iter=1):
24
  buffered_init_img = BytesIO()
 
92
  # output the sampled images
93
  def main(user_image):
94
  # accept the image as input
95
+ pillow_heif.register_heif_opener()
 
 
96
  init_image = PIL.Image.open(user_image).convert("RGB")
97
  # # resize the image to be (512, 512)
98
  newsize = (512, 512)