Nathan12 commited on
Commit
3f80e8d
·
1 Parent(s): fb8c9f2

update plot

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -267,7 +267,7 @@ def optimize_model(model, sparsity, context, criteria):
267
  def create_size_comparison_plot(before_results, after_results, metrics):
268
  sns.set_style("darkgrid")
269
  # Increase figure size height to accommodate labels better
270
- fig = plt.figure(figsize=(10, 6), dpi=150)
271
  fig.patch.set_alpha(0.0)
272
  ax = plt.gca()
273
  ax.patch.set_alpha(0.0)
@@ -307,17 +307,17 @@ def create_size_comparison_plot(before_results, after_results, metrics):
307
  plt.text(bar.get_x() + bar.get_width()/2., height + offset,
308
  format_value(height, metrics),
309
  ha='center', va='bottom',
310
- fontsize=11,
311
  fontweight='bold',
312
  color='white')
313
  compression_ratio = ((before_results - after_results) / before_results) * 100 if before_results else 0
314
  plt.title(f'Model Compression: {compression_ratio:.1f}%',
315
- fontsize=14,
316
  fontweight='bold',
317
  pad=20,
318
  color='white')
319
- plt.xlabel('Model Version', fontsize=12, fontweight='bold', labelpad=10, color='white')
320
- plt.ylabel(unit_label_map.get(metrics, metrics), fontsize=12, fontweight='bold', labelpad=10, color='white')
321
  ax.grid(alpha=0.2, color='gray')
322
  sns.despine()
323
  # Use scientific notation for small Energy/Emissions values
@@ -330,13 +330,18 @@ def create_size_comparison_plot(before_results, after_results, metrics):
330
  plt.ylim(0, max_value * 1.3) # Increased upper limit
331
  plt.yticks(np.linspace(0, max_value * 1.3, 10))
332
  ax.tick_params(colors='white')
 
 
 
 
333
  for spine in ax.spines.values():
334
  spine.set_color('white')
335
  ax.xaxis.label.set_color('white')
336
  ax.yaxis.label.set_color('white')
337
  ax.tick_params(axis='x', colors='white')
338
  ax.tick_params(axis='y', colors='white')
339
- ax.yaxis.set_major_formatter(plt.FuncFormatter(lambda x, p: f'{x:.1f}'))
 
340
  plt.tight_layout(pad=3.5) # Increased padding from 2.5 to 3.5
341
  return fig
342
 
 
267
  def create_size_comparison_plot(before_results, after_results, metrics):
268
  sns.set_style("darkgrid")
269
  # Increase figure size height to accommodate labels better
270
+ fig = plt.figure(figsize=(12, 7), dpi=150)
271
  fig.patch.set_alpha(0.0)
272
  ax = plt.gca()
273
  ax.patch.set_alpha(0.0)
 
307
  plt.text(bar.get_x() + bar.get_width()/2., height + offset,
308
  format_value(height, metrics),
309
  ha='center', va='bottom',
310
+ fontsize=15,
311
  fontweight='bold',
312
  color='white')
313
  compression_ratio = ((before_results - after_results) / before_results) * 100 if before_results else 0
314
  plt.title(f'Model Compression: {compression_ratio:.1f}%',
315
+ fontsize=18,
316
  fontweight='bold',
317
  pad=20,
318
  color='white')
319
+ plt.xlabel('Model Version', fontsize=15, fontweight='bold', labelpad=10, color='white')
320
+ plt.ylabel(unit_label_map.get(metrics, metrics), fontsize=15, fontweight='bold', labelpad=10, color='white')
321
  ax.grid(alpha=0.2, color='gray')
322
  sns.despine()
323
  # Use scientific notation for small Energy/Emissions values
 
330
  plt.ylim(0, max_value * 1.3) # Increased upper limit
331
  plt.yticks(np.linspace(0, max_value * 1.3, 10))
332
  ax.tick_params(colors='white')
333
+ ax.tick_params(axis='x', colors='white', labelsize=16)
334
+ ax.tick_params(axis='y', colors='white', labelsize=15)
335
+ for tick_label in ax.get_xticklabels():
336
+ tick_label.set_fontweight('bold')
337
  for spine in ax.spines.values():
338
  spine.set_color('white')
339
  ax.xaxis.label.set_color('white')
340
  ax.yaxis.label.set_color('white')
341
  ax.tick_params(axis='x', colors='white')
342
  ax.tick_params(axis='y', colors='white')
343
+ if metrics not in ('Energy', 'Emissions'):
344
+ ax.yaxis.set_major_formatter(plt.FuncFormatter(lambda x, p: f'{x:.1f}'))
345
  plt.tight_layout(pad=3.5) # Increased padding from 2.5 to 3.5
346
  return fig
347