PabloTJ commited on
Commit
ad47898
·
verified ·
1 Parent(s): ec2f5cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -3,6 +3,7 @@ from transformers import pipeline, set_seed
3
  import re
4
  import numpy as np
5
  import pandas as pd
 
6
 
7
  # Set a seed for reproducibility
8
  set_seed(42)
@@ -80,7 +81,7 @@ def extract_score(text):
80
  return min(max(score, 0), 100)
81
  return 0
82
 
83
- # Main benchmark function that runs all tests at once and saves results to a CSV file.
84
  def run_benchmark_all():
85
  results = []
86
 
@@ -125,21 +126,22 @@ def run_benchmark_all():
125
  # Create DataFrame and sort by Final Score.
126
  df = pd.DataFrame(results).sort_values(by="Final Score", ascending=False).reset_index(drop=True)
127
 
128
- # Save results to CSV file.
129
  csv_path = "benchmark_results.csv"
130
  df.to_csv(csv_path, index=False)
 
131
 
 
132
  return gr.Dataframe(df), csv_path
133
 
134
- # Gradio UI using Blocks for a canvas layout.
135
  with gr.Blocks(title="Premium Model Palindrome Benchmark") as demo:
136
  gr.Markdown("# Premium Model Palindrome Benchmark")
137
- gr.Markdown("This benchmark runs automatically over 2 premium text-generation models across 5 languages (English, German, Spanish, French, Portuguese), and saves the results to a CSV file for later review.")
138
 
139
  with gr.Row():
140
  run_button = gr.Button("Run All Benchmarks")
141
 
142
- # The interface now outputs both a DataFrame and a File Download.
143
  output_table = gr.Dataframe(label="Benchmark Results")
144
  output_file = gr.File(label="Download CSV Results")
145
 
 
3
  import re
4
  import numpy as np
5
  import pandas as pd
6
+ import os
7
 
8
  # Set a seed for reproducibility
9
  set_seed(42)
 
81
  return min(max(score, 0), 100)
82
  return 0
83
 
84
+ # Main benchmark function that runs all tests at once and saves results automatically.
85
  def run_benchmark_all():
86
  results = []
87
 
 
126
  # Create DataFrame and sort by Final Score.
127
  df = pd.DataFrame(results).sort_values(by="Final Score", ascending=False).reset_index(drop=True)
128
 
129
+ # Automatically save results to a CSV file.
130
  csv_path = "benchmark_results.csv"
131
  df.to_csv(csv_path, index=False)
132
+ print(f"CSV file saved to {os.path.abspath(csv_path)}")
133
 
134
+ # Return both the DataFrame and the CSV file path for download.
135
  return gr.Dataframe(df), csv_path
136
 
137
+ # Build the Gradio UI using Blocks for a canvas layout.
138
  with gr.Blocks(title="Premium Model Palindrome Benchmark") as demo:
139
  gr.Markdown("# Premium Model Palindrome Benchmark")
140
+ gr.Markdown("This benchmark runs automatically over 2 premium text-generation models across 5 languages (English, German, Spanish, French, Portuguese) and saves the results to a CSV file when done.")
141
 
142
  with gr.Row():
143
  run_button = gr.Button("Run All Benchmarks")
144
 
 
145
  output_table = gr.Dataframe(label="Benchmark Results")
146
  output_file = gr.File(label="Download CSV Results")
147