krrishD commited on
Commit
2fc1ecf
1 Parent(s): 9a7567c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -17,13 +17,19 @@ import base64
17
  from io import BytesIO
18
  import os
19
  from PIL import Image
20
- import gdown
21
  import face_recognition
 
 
22
 
23
- def download_gdrive_url():
24
- url = 'https://drive.google.com/u/0/uc?id=1PPO2MCttsmSqyB-vKh5C7SumwFKuhgyj&export=download'
25
- output = 'haarcascade_frontalface_default.xml'
26
- gdown.download(url, output, quiet=False)
 
 
 
 
 
27
 
28
  def inpaint(p, init_image, mask_image=None, strength=0.75, guidance_scale=7.5, generator=None, num_samples=1, n_iter=1):
29
  buffered_init_img = BytesIO()
@@ -97,6 +103,7 @@ def preprocess_mask(mask):
97
  # output the sampled images
98
  def main(user_image):
99
  # accept the image as input
 
100
  init_image = PIL.Image.open(user_image).convert("RGB")
101
  # # resize the image to be (512, 512)
102
  newsize = (512, 512)
 
17
  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
  # output the sampled images
104
  def main(user_image):
105
  # accept the image as input
106
+ decodeImage(data, user_image.name)
107
  init_image = PIL.Image.open(user_image).convert("RGB")
108
  # # resize the image to be (512, 512)
109
  newsize = (512, 512)