user-agent commited on
Commit
7bacd5d
·
verified ·
1 Parent(s): 45b2f13

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -10
app.py CHANGED
@@ -429,16 +429,9 @@ def get_cropped_images(images,category):
429
  continue
430
 
431
  cropped_list.append(image)
432
- base64_images = []
433
- for crop in cropped_list:
434
- # Create a BytesIO object to temporarily hold the image data
435
- with io.BytesIO() as buffer:
436
- # Save the image to the BytesIO object
437
- crop.save(buffer, format="JPG")
438
- # Encode the image data to base64
439
- base64_image = base64.b64encode(buffer.getvalue()).decode("utf-8")
440
- # Append the base64 encoded image to the list
441
- base64_images.append(base64_image)
442
 
443
  return base64_images
444
 
 
429
  continue
430
 
431
  cropped_list.append(image)
432
+
433
+ base64_images = [base64.b64encode(BytesIO(image.save(format='JPG')).getvalue()).decode('utf-8') for image in cropped_list]
434
+
 
 
 
 
 
 
 
435
 
436
  return base64_images
437