hecl commited on
Commit
d6a239d
1 Parent(s): 0da2d4c

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

Browse files
Files changed (1) hide show
  1. app.py +9 -13
app.py CHANGED
@@ -73,44 +73,40 @@ def compare_score(score, score_list):
73
  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=(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)
 
73
  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=(8, 6))
78
 
79
+ # Create vertical bars
80
  bars = ax.bar(labels, scores, color=base_colors, edgecolor='black', width=0.6)
81
 
 
 
 
 
82
  # Adding the text labels for scores
83
  for bar, score in zip(bars, scores):
84
  height = bar.get_height()
85
+ ax.annotate(f'{score:.1f}',
86
  xy=(bar.get_x() + bar.get_width() / 2, height),
87
  xytext=(0, 3), # 3 points vertical offset
88
  textcoords="offset points",
89
  ha='center', va='bottom',
90
  color='black')
91
+
92
  # Add comparison text
93
  comparison_texts = []
94
+ for i, (bar, score) in enumerate(zip(bars, scores)):
95
  percentage = (np.sum(comparisons[i] < score) / len(comparisons[i])) * 100
96
  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'
97
  comparison_texts.append(comparison_text)
98
  ax.annotate(comparison_text,
99
+ xy=(bar.get_x() + bar.get_width(), bar.get_height() / 2),
100
  xytext=(5, 0), # 5 points horizontal offset
101
  textcoords="offset points",
102
  ha='left', va='center',
103
+ color=base_colors[i])
104
+
105
  ax.set_xlabel('Categories')
106
  ax.set_ylabel('Scores')
107
  ax.set_ylim(0, 5)
108
  ax.set_title('Video Quality Scores')
109
+
110
  plt.tight_layout()
111
  image_path = "./scores_bar_chart.png"
112
  plt.savefig(image_path)