alperugurcan commited on
Commit
8314d9c
·
verified ·
1 Parent(s): f435603

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
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
- # Example images for testing
7
- example_images = [
8
- "https://i.imgur.com/kZrw9B0.jpeg", # Example Image 1
9
- "https://i.imgur.com/AKgF4Xs.jpeg" # Example Image 2
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=example_images # Adding example images to the interface
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()