Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -46,11 +46,17 @@ def crop_face(base64_image):
|
|
46 |
|
47 |
|
48 |
def image_to_base64(image):
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
# Define the Gradio interfaces
|
56 |
face_crop_interface = gr.Interface(
|
|
|
46 |
|
47 |
|
48 |
def image_to_base64(image):
|
49 |
+
try:
|
50 |
+
# Prepare the buffer to save the image
|
51 |
+
buffered = BytesIO()
|
52 |
+
# Save the image to the buffer in JPEG format
|
53 |
+
image.save(buffered, format="JPEG")
|
54 |
+
# Encode the buffered image to Base64
|
55 |
+
img_str = base64.b64encode(buffered.getvalue()).decode('utf-8')
|
56 |
+
return img_str
|
57 |
+
except Exception as e:
|
58 |
+
return f"An error occurred: {str(e)}"
|
59 |
+
|
60 |
|
61 |
# Define the Gradio interfaces
|
62 |
face_crop_interface = gr.Interface(
|