rbgo commited on
Commit
bb9fdf4
β€’
1 Parent(s): c514c0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -59
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
  import pandas as pd
3
- import os
4
- import shutil
5
 
6
  # Description and Introduction texts
7
  DESCRIPTION = """
@@ -39,61 +39,26 @@ HOW_WE_TESTED = """
39
  </div>
40
  """
41
 
42
- csv_folder_path = 'result_csv/'
 
43
 
44
- UPLOAD_SECRET = os.getenv("UPLOAD_SECRET")
45
-
46
- # ... [Previous functions remain the same: read_and_process_csv_files, get_leaderboard_df, filter_and_search] ...
47
-
48
- def add_new_entry(file, password):
49
- global df
50
- if file is None:
51
- return df, "No file uploaded."
52
-
53
- if password != UPLOAD_SECRET:
54
- return df, "Incorrect password. Upload failed."
55
-
56
- new_df = pd.read_csv(file.name)
57
 
58
  columns_order = [
59
  "Model_Name", "Library", "TTFT", "Tokens-per-Second", "Token_Count",
60
  "Input_Tokens", "Output_Tokens"
61
  ]
62
- for col in columns_order:
63
- if col not in new_df.columns:
64
- new_df[col] = pd.NA
65
- new_df = new_df[columns_order]
66
-
67
- df = pd.concat([df, new_df], ignore_index=True)
68
-
69
- filename = os.path.basename(file.name)
70
- destination = os.path.join(csv_folder_path, filename)
71
- shutil.copy(file.name, destination)
72
-
73
- return df, f"File '{filename}' uploaded and data added successfully!"
74
-
75
- def read_and_process_csv_files(folder_path):
76
- all_data = []
77
- for filename in os.listdir(folder_path):
78
- if filename.endswith('.csv'):
79
- file_path = os.path.join(folder_path, filename)
80
- df = pd.read_csv(file_path)
81
- all_data.append(df)
82
-
83
- combined_df = pd.concat(all_data, ignore_index=True)
84
-
85
- columns_order = [
86
- "Model_Name", "Library", "TTFT", "Tokens-per-Second", "Token_Count",
87
- "input_length", "output_length"
88
- ]
89
 
90
  for col in columns_order:
91
- if col not in combined_df.columns:
92
- combined_df[col] = pd.NA
93
 
94
- return combined_df[columns_order]
95
 
96
- df = read_and_process_csv_files(csv_folder_path)
97
 
98
  def get_leaderboard_df():
99
  return df
@@ -177,18 +142,6 @@ with gr.Blocks(css=custom_css) as demo:
177
  leaderboard = gr.DataFrame(df)
178
 
179
  gr.HTML(HOW_WE_TESTED)
180
-
181
- with gr.TabItem("βž• Add New Entry"):
182
- file_upload = gr.File(label="πŸ“ Upload CSV File")
183
- password_input = gr.Textbox(label="πŸ” Upload Password", type="password")
184
- submit_button = gr.Button("πŸ“€ Add Entry", variant="primary")
185
- result = gr.Markdown()
186
-
187
- submit_button.click(
188
- add_new_entry,
189
- inputs=[file_upload, password_input],
190
- outputs=[leaderboard, result]
191
- )
192
 
193
  search_input.change(filter_and_search, inputs=[search_input, library_dropdown], outputs=leaderboard)
194
  library_dropdown.change(filter_and_search, inputs=[search_input, library_dropdown], outputs=leaderboard)
 
1
  import gradio as gr
2
  import pandas as pd
3
+ import requests
4
+ from io import StringIO
5
 
6
  # Description and Introduction texts
7
  DESCRIPTION = """
 
39
  </div>
40
  """
41
 
42
+ # URL of the CSV file
43
+ CSV_URL = "hf://datasets/rbgo/llm-inference-benchmark/resolve/main/LLM-inference-benchmark-3.csv"
44
 
45
+ def load_and_process_csv():
46
+ response = requests.get(CSV_URL)
47
+ csv_content = StringIO(response.text)
48
+ df = pd.read_csv(csv_content)
 
 
 
 
 
 
 
 
 
49
 
50
  columns_order = [
51
  "Model_Name", "Library", "TTFT", "Tokens-per-Second", "Token_Count",
52
  "Input_Tokens", "Output_Tokens"
53
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  for col in columns_order:
56
+ if col not in df.columns:
57
+ df[col] = pd.NA
58
 
59
+ return df[columns_order]
60
 
61
+ df = load_and_process_csv()
62
 
63
  def get_leaderboard_df():
64
  return df
 
142
  leaderboard = gr.DataFrame(df)
143
 
144
  gr.HTML(HOW_WE_TESTED)
 
 
 
 
 
 
 
 
 
 
 
 
145
 
146
  search_input.change(filter_and_search, inputs=[search_input, library_dropdown], outputs=leaderboard)
147
  library_dropdown.change(filter_and_search, inputs=[search_input, library_dropdown], outputs=leaderboard)