xtlyxt commited on
Commit
f89a541
·
verified ·
1 Parent(s): 1423812

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -14
app.py CHANGED
@@ -4,16 +4,15 @@ from transformers import pipeline
4
  import pandas as pd
5
  import matplotlib.pyplot as plt
6
 
 
 
 
7
  # Create an image classification pipeline with scores
8
  pipe = pipeline("image-classification", model="trpakov/vit-face-expression", top_k=None)
9
 
10
  # Streamlit app
11
  st.title("Emotion Recognition with vit-face-expression")
12
 
13
- # Slider example
14
- #x = st.slider('Select a value')
15
- #st.write(f"{x} squared is {x * x}")
16
-
17
  # Upload images
18
  uploaded_images = st.file_uploader("Upload images", type=["jpg", "png"], accept_multiple_files=True)
19
 
@@ -77,16 +76,16 @@ if st.button("Predict Emotions") and selected_images:
77
 
78
  # Plot pie chart
79
  st.write("Emotion Distribution (Pie Chart):")
80
- plt.figure(figsize=(8, 6))
81
- plt.pie(emotion_counts, labels=emotion_counts.index, autopct='%1.1f%%', startangle=140)
82
- plt.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
83
- st.pyplot()
84
 
85
  # Plot bar chart
86
  st.write("Emotion Distribution (Bar Chart):")
87
- plt.figure(figsize=(10, 6))
88
- emotion_counts.plot(kind='bar', color='skyblue')
89
- plt.xlabel('Emotion')
90
- plt.ylabel('Count')
91
- plt.title('Emotion Distribution')
92
- st.pyplot()
 
4
  import pandas as pd
5
  import matplotlib.pyplot as plt
6
 
7
+ # Disable PyplotGlobalUseWarning
8
+ st.set_option('deprecation.showPyplotGlobalUse', False)
9
+
10
  # Create an image classification pipeline with scores
11
  pipe = pipeline("image-classification", model="trpakov/vit-face-expression", top_k=None)
12
 
13
  # Streamlit app
14
  st.title("Emotion Recognition with vit-face-expression")
15
 
 
 
 
 
16
  # Upload images
17
  uploaded_images = st.file_uploader("Upload images", type=["jpg", "png"], accept_multiple_files=True)
18
 
 
76
 
77
  # Plot pie chart
78
  st.write("Emotion Distribution (Pie Chart):")
79
+ fig_pie, ax_pie = plt.subplots()
80
+ ax_pie.pie(emotion_counts, labels=emotion_counts.index, autopct='%1.1f%%', startangle=140)
81
+ ax_pie.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
82
+ st.pyplot(fig_pie)
83
 
84
  # Plot bar chart
85
  st.write("Emotion Distribution (Bar Chart):")
86
+ fig_bar, ax_bar = plt.subplots()
87
+ emotion_counts.plot(kind='bar', color='skyblue', ax=ax_bar)
88
+ ax_bar.set_xlabel('Emotion')
89
+ ax_bar.set_ylabel('Count')
90
+ ax_bar.set_title('Emotion Distribution')
91
+ st.pyplot(fig_bar)