hecl commited on
Commit
0da2d4c
·
1 Parent(s): 610f595

- [MINOR] [SOURCE] [UPDATE] 1. update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -21
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=(10, 5))
 
 
 
 
 
 
 
78
 
79
- for i, (label, score, comparison, base_color) in enumerate(zip(labels, scores, comparisons, base_colors)):
80
- gradient = patches.Rectangle((0, i), 5, 1, color=base_color, alpha=0.5)
81
- ax.add_patch(gradient)
82
-
83
- # Add the actual score line
84
- ax.plot([score, score], [i, i+0.9], color='black', linewidth=2)
85
-
86
- ax.text(score + 0.1, i + 0.5, f'{score:.1f}', va='center', ha='left', color=base_color)
87
- ax.text(5.1, i + 0.5, comparison, va='center', ha='left', color=base_color)
88
 
89
- ax.set_yticks(range(len(labels)))
90
- ax.set_yticklabels(labels)
91
- for tick, color in zip(ax.get_yticklabels(), base_colors):
92
- tick.set_color(color)
93
- ax.set_xticks([0, 1, 2, 3, 4, 5])
94
- ax.set_xticklabels([0, 1, 2, 3, 4, 5])
95
- ax.set_xlim(0, 5)
96
- ax.set_xlabel('Score')
 
 
 
 
 
 
 
 
 
97
 
98
  plt.tight_layout()
99
- image_path = "./bar_chart.png"
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):