user-agent
commited on
Commit
•
27b0146
1
Parent(s):
d3bf39d
Update app.py
Browse files
app.py
CHANGED
@@ -400,6 +400,14 @@ def get_objects(image, threshold=0.8):
|
|
400 |
|
401 |
return class_counts, output_img, crops, crop_classes
|
402 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
403 |
|
404 |
|
405 |
def get_cropped_images(images,category):
|
@@ -431,7 +439,7 @@ def get_cropped_images(images,category):
|
|
431 |
cropped_list.append(image)
|
432 |
|
433 |
|
434 |
-
base64_images =
|
435 |
|
436 |
return base64_images
|
437 |
|
|
|
400 |
|
401 |
return class_counts, output_img, crops, crop_classes
|
402 |
|
403 |
+
def encode_images_to_base64(cropped_list):
|
404 |
+
base64_images = []
|
405 |
+
for image in cropped_list:
|
406 |
+
with io.BytesIO() as buffer:
|
407 |
+
image.convert('RGB').save(buffer, format='JPEG')
|
408 |
+
base64_image = base64.b64encode(buffer.getvalue()).decode('utf-8')
|
409 |
+
base64_images.append(base64_image)
|
410 |
+
return base64_images
|
411 |
|
412 |
|
413 |
def get_cropped_images(images,category):
|
|
|
439 |
cropped_list.append(image)
|
440 |
|
441 |
|
442 |
+
base64_images = encode_images_to_base64(cropped_list)
|
443 |
|
444 |
return base64_images
|
445 |
|