badaoui HF Staff commited on
Commit
871d304
·
1 Parent(s): 5309153

Remove logo images and use simple text labels

Browse files

- Replace logo boxes with simple text labels for AMD and NVIDIA
- Remove unused imports (matplotlib.offsetbox, FancyBboxPatch, mpimg, os)
- Simplify draw_text_and_bar function (was draw_logo_and_bar)
- Text labels now use subtle red background when failures present
- Reduces code complexity and removes dependency on logo image files

Files changed (1) hide show
  1. summary_page.py +13 -86
summary_page.py CHANGED
@@ -1,9 +1,5 @@
1
  import matplotlib.pyplot as plt
2
  import pandas as pd
3
- from matplotlib.offsetbox import OffsetImage, AnnotationBbox
4
- from matplotlib.patches import FancyBboxPatch
5
- import matplotlib.image as mpimg
6
- import os
7
  from data import extract_model_data
8
 
9
  # Layout parameters
@@ -41,21 +37,6 @@ LABEL_FONT_SIZE = 14
41
  LABEL_OFFSET = 1
42
  FAILURE_RATE_FONT_SIZE = 28
43
 
44
- # Logo settings
45
- LOGO_BOX_WIDTH = 4.5
46
- LOGO_BOX_HEIGHT = 0.43
47
- LOGO_ZOOM = 0.09
48
-
49
- # Load logos once at module level
50
- SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
51
- try:
52
- AMD_LOGO = mpimg.imread(os.path.join(SCRIPT_DIR, 'logos/amd_logo.png'))
53
- except:
54
- AMD_LOGO = None
55
- try:
56
- NVIDIA_LOGO = mpimg.imread(os.path.join(SCRIPT_DIR, 'logos/nvidia_logo.png'))
57
- except:
58
- NVIDIA_LOGO = None
59
 
60
 
61
  def calculate_overall_failure_rates(df: pd.DataFrame, available_models: list[str]) -> tuple[float, float]:
@@ -93,7 +74,7 @@ def calculate_overall_failure_rates(df: pd.DataFrame, available_models: list[str
93
  return amd_failure_rate, nvidia_failure_rate
94
 
95
 
96
- def draw_logo_and_bar(
97
  label: str,
98
  stats: dict[str, int],
99
  y_bar: float,
@@ -101,72 +82,19 @@ def draw_logo_and_bar(
101
  bar_height: float,
102
  ax: plt.Axes,
103
  ) -> None:
104
- """Draw a horizontal bar chart for given stats with a logo box on the left."""
105
- # Determine if there are failures
 
106
  failures_present = any(stats[category] > 0 for category in ['failed', 'error'])
107
-
108
- # Select the appropriate logo
109
- logo = AMD_LOGO if label.lower() == "amd" else NVIDIA_LOGO
110
-
111
- # Calculate box position (centered on the bar vertically)
112
- box_x = column_left_position - LABEL_OFFSET - LOGO_BOX_WIDTH
113
- box_y = y_bar - LOGO_BOX_HEIGHT / 2
114
-
115
- # Draw the colored box
116
  if failures_present:
117
- box_color = COLORS['failed'] # Red for failures
118
- box_alpha = 0.6
119
  else:
120
- box_color = '#2a2a2a' # Dark gray for no failures
121
- box_alpha = 0.5
122
-
123
- box = FancyBboxPatch(
124
- (box_x, box_y),
125
- LOGO_BOX_WIDTH,
126
- LOGO_BOX_HEIGHT,
127
- boxstyle="round,pad=0.05",
128
- facecolor=box_color,
129
- edgecolor='#444444',
130
- linewidth=1,
131
- alpha=box_alpha
132
  )
133
- ax.add_patch(box)
134
-
135
- # Add logo image inside the box if available
136
- if logo is not None:
137
- try:
138
- imagebox = OffsetImage(logo, zoom=LOGO_ZOOM)
139
- ab = AnnotationBbox(
140
- imagebox,
141
- (box_x + LOGO_BOX_WIDTH / 2, y_bar),
142
- frameon=False,
143
- box_alignment=(0.5, 0.5)
144
- )
145
- ax.add_artist(ab)
146
- except:
147
- # Fallback to text if logo doesn't work
148
- ax.text(
149
- box_x + LOGO_BOX_WIDTH / 2, y_bar,
150
- label.upper(),
151
- ha='center', va='center',
152
- color='#FFFFFF',
153
- fontsize=10,
154
- fontfamily='monospace',
155
- fontweight='bold'
156
- )
157
- else:
158
- # Fallback to text if logo not loaded
159
- ax.text(
160
- box_x + LOGO_BOX_WIDTH / 2, y_bar,
161
- label.upper(),
162
- ha='center', va='center',
163
- color='#FFFFFF',
164
- fontsize=10,
165
- fontfamily='monospace',
166
- fontweight='bold'
167
- )
168
-
169
- # Draw the bar
170
  total = sum(stats.values())
171
  if total > 0:
172
  left = column_left_position
@@ -258,10 +186,9 @@ def create_summary_page(df: pd.DataFrame, available_models: list[str]) -> plt.Fi
258
 
259
  # AMD label and bar in this column
260
  bar_height = min(0.4, vertical_spacing * BAR_HEIGHT_RATIO)
261
- # Draw AMD bar with logo
262
- draw_logo_and_bar("amd", amd_stats, y_amd_bar, col_left, bar_height, ax)
263
- # Draw NVIDIA bar with logo
264
- draw_logo_and_bar("nvidia", nvidia_stats, y_nvidia_bar, col_left, bar_height, ax)
265
 
266
  # Increment counter for next visible model
267
  visible_model_count += 1
 
1
  import matplotlib.pyplot as plt
2
  import pandas as pd
 
 
 
 
3
  from data import extract_model_data
4
 
5
  # Layout parameters
 
37
  LABEL_OFFSET = 1
38
  FAILURE_RATE_FONT_SIZE = 28
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
 
42
  def calculate_overall_failure_rates(df: pd.DataFrame, available_models: list[str]) -> tuple[float, float]:
 
74
  return amd_failure_rate, nvidia_failure_rate
75
 
76
 
77
+ def draw_text_and_bar(
78
  label: str,
79
  stats: dict[str, int],
80
  y_bar: float,
 
82
  bar_height: float,
83
  ax: plt.Axes,
84
  ) -> None:
85
+ """Draw a horizontal bar chart for given stats and its label on the left."""
86
+ # Text
87
+ label_x = column_left_position - LABEL_OFFSET
88
  failures_present = any(stats[category] > 0 for category in ['failed', 'error'])
 
 
 
 
 
 
 
 
 
89
  if failures_present:
90
+ props = dict(boxstyle='round', facecolor=COLORS['failed'], alpha=0.35)
 
91
  else:
92
+ props = dict(alpha=0)
93
+ ax.text(
94
+ label_x, y_bar, label, ha='right', va='center', color='#CCCCCC', fontsize=LABEL_FONT_SIZE,
95
+ fontfamily='monospace', fontweight='normal', bbox=props
 
 
 
 
 
 
 
 
96
  )
97
+ # Bar
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  total = sum(stats.values())
99
  if total > 0:
100
  left = column_left_position
 
186
 
187
  # AMD label and bar in this column
188
  bar_height = min(0.4, vertical_spacing * BAR_HEIGHT_RATIO)
189
+ draw_text_and_bar("amd", amd_stats, y_amd_bar, col_left, bar_height, ax)
190
+
191
+ draw_text_and_bar("nvidia", nvidia_stats, y_nvidia_bar, col_left, bar_height, ax)
 
192
 
193
  # Increment counter for next visible model
194
  visible_model_count += 1