Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,12 +2,17 @@ import gradio as gr
|
|
2 |
from deepface import DeepFace
|
3 |
from PIL import Image
|
4 |
import numpy as np
|
|
|
5 |
|
6 |
-
#
|
7 |
-
|
8 |
-
"
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# Analyze the uploaded image
|
13 |
def analyze_face(image):
|
@@ -33,8 +38,8 @@ iface = gr.Interface(
|
|
33 |
gr.Text(label="Race"),
|
34 |
gr.Text(label="Dominant Emotion"),
|
35 |
gr.Text(label="Emotion Breakdown")],
|
36 |
-
examples=
|
37 |
)
|
38 |
|
39 |
# Launch the Gradio app
|
40 |
-
iface.launch()
|
|
|
2 |
from deepface import DeepFace
|
3 |
from PIL import Image
|
4 |
import numpy as np
|
5 |
+
import base64
|
6 |
|
7 |
+
# Function to encode images in base64
|
8 |
+
def encode_image(image_path):
|
9 |
+
with open(image_path, "rb") as image_file:
|
10 |
+
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
|
11 |
+
return f"data:image/jpeg;base64,{encoded_string}"
|
12 |
+
|
13 |
+
# Example images as base64 strings (You need to download the images first)
|
14 |
+
example_image_1 = encode_image("e.jpeg") # Replace with your local image path
|
15 |
+
example_image_2 = encode_image("k.jpeg") # Replace with your local image path
|
16 |
|
17 |
# Analyze the uploaded image
|
18 |
def analyze_face(image):
|
|
|
38 |
gr.Text(label="Race"),
|
39 |
gr.Text(label="Dominant Emotion"),
|
40 |
gr.Text(label="Emotion Breakdown")],
|
41 |
+
examples=[[example_image_1], [example_image_2]] # Adding example images
|
42 |
)
|
43 |
|
44 |
# Launch the Gradio app
|
45 |
+
iface.launch()
|