hecl
commited on
Commit
·
0da2d4c
1
Parent(s):
610f595
- [MINOR] [SOURCE] [UPDATE] 1. update app.py
Browse files
app.py
CHANGED
@@ -74,32 +74,47 @@ def create_bar_chart(scores, comparisons):
|
|
74 |
labels = ['Semantic', 'Aesthetic', 'Technical', 'Overall']
|
75 |
base_colors = ['#d62728', '#ff7f0e', '#1f77b4', '#bcbd22']
|
76 |
|
77 |
-
fig, ax = plt.subplots(figsize=(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
for
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
plt.tight_layout()
|
99 |
-
image_path = "./
|
100 |
plt.savefig(image_path)
|
101 |
-
plt.close()
|
102 |
-
|
103 |
return image_path
|
104 |
|
105 |
def inference_one_video(input_video):
|
|
|
74 |
labels = ['Semantic', 'Aesthetic', 'Technical', 'Overall']
|
75 |
base_colors = ['#d62728', '#ff7f0e', '#1f77b4', '#bcbd22']
|
76 |
|
77 |
+
fig, ax = plt.subplots(figsize=(8, 6))
|
78 |
+
|
79 |
+
# Create a bar chart with vertical bars
|
80 |
+
bars = ax.bar(labels, scores, color=base_colors, edgecolor='black', width=0.6)
|
81 |
+
|
82 |
+
# Add gradient effect
|
83 |
+
for bar, color in zip(bars, base_colors):
|
84 |
+
bar.set_facecolor(plt.cm.get_cmap('autumn')(bar.get_height() / 5))
|
85 |
|
86 |
+
# Adding the text labels for scores
|
87 |
+
for bar, score in zip(bars, scores):
|
88 |
+
height = bar.get_height()
|
89 |
+
ax.annotate(f'{score}',
|
90 |
+
xy=(bar.get_x() + bar.get_width() / 2, height),
|
91 |
+
xytext=(0, 3), # 3 points vertical offset
|
92 |
+
textcoords="offset points",
|
93 |
+
ha='center', va='bottom',
|
94 |
+
color='black')
|
95 |
|
96 |
+
# Add comparison text
|
97 |
+
comparison_texts = []
|
98 |
+
for i, score in enumerate(scores):
|
99 |
+
percentage = (np.sum(comparisons[i] < score) / len(comparisons[i])) * 100
|
100 |
+
comparison_text = f'Better than {percentage:.0f}% videos in YT-UGC' if percentage > 50 else f'Worse than {100 - percentage:.0f}% videos in YT-UGC'
|
101 |
+
comparison_texts.append(comparison_text)
|
102 |
+
ax.annotate(comparison_text,
|
103 |
+
xy=(bar.get_x() + bar.get_width(), height),
|
104 |
+
xytext=(5, 0), # 5 points horizontal offset
|
105 |
+
textcoords="offset points",
|
106 |
+
ha='left', va='center',
|
107 |
+
color=color)
|
108 |
+
|
109 |
+
ax.set_xlabel('Categories')
|
110 |
+
ax.set_ylabel('Scores')
|
111 |
+
ax.set_ylim(0, 5)
|
112 |
+
ax.set_title('Video Quality Scores')
|
113 |
|
114 |
plt.tight_layout()
|
115 |
+
image_path = "./scores_bar_chart.png"
|
116 |
plt.savefig(image_path)
|
117 |
+
plt.close(fig)
|
|
|
118 |
return image_path
|
119 |
|
120 |
def inference_one_video(input_video):
|