DanielPFlorian commited on
Commit
6edc1b2
·
1 Parent(s): 6d7369a

Change image format

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -103,6 +103,7 @@ def process_image(img_path):
103
  image: path of the image to be processed
104
  """
105
  inp = Image.open(img_path)
 
106
  exif = inp.getexif()
107
 
108
  # Get image size
@@ -114,13 +115,13 @@ def process_image(img_path):
114
  # Remove non alphanumeric characters
115
  image_path = str(datetime.now())
116
  image_path = re.sub(r"\W+", "_", image_path)
117
- image_path = image_path + ".png"
118
 
119
  # Join to directory path
120
  inf_image = os.path.join("inference", image_path)
121
 
122
  # Use repo for inference
123
- inp.save(inf_image, exif=exif)
124
  HfApi().upload_file(
125
  path_or_fileobj=inf_image,
126
  path_in_repo=image_path,
 
103
  image: path of the image to be processed
104
  """
105
  inp = Image.open(img_path)
106
+ inp.load()
107
  exif = inp.getexif()
108
 
109
  # Get image size
 
115
  # Remove non alphanumeric characters
116
  image_path = str(datetime.now())
117
  image_path = re.sub(r"\W+", "_", image_path)
118
+ image_path = image_path + ".jpg"
119
 
120
  # Join to directory path
121
  inf_image = os.path.join("inference", image_path)
122
 
123
  # Use repo for inference
124
+ inp.save(inf_image, quality=95, keep=True, exif=exif)
125
  HfApi().upload_file(
126
  path_or_fileobj=inf_image,
127
  path_in_repo=image_path,