Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -46,34 +46,92 @@ def main():
|
|
46 |
|
47 |
st.sidebar.markdown("<hr style='border: 1px solid gray; margin: 15px 0;'>", unsafe_allow_html=True)
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
return
|
58 |
-
|
59 |
-
|
|
|
|
|
60 |
required_columns = ["model", "provider", "date", "task", "hardware", "energy", "score"]
|
61 |
for col in required_columns:
|
62 |
if col not in data_df.columns:
|
63 |
st.sidebar.error(f"The CSV file must contain a column named '{col}'.")
|
64 |
return
|
65 |
|
66 |
-
st.sidebar.write("### Instructions:")
|
67 |
-
st.sidebar.write("#### 1. Select a model below")
|
68 |
-
|
69 |
model_options = data_df["model"].unique().tolist()
|
70 |
selected_model = st.sidebar.selectbox(
|
71 |
"Scored Models",
|
72 |
model_options,
|
73 |
help="Start typing to search for a model"
|
74 |
)
|
75 |
-
|
76 |
-
|
77 |
model_data = data_df[data_df["model"] == selected_model].iloc[0]
|
78 |
|
79 |
# Select background by score
|
@@ -138,7 +196,7 @@ def create_label_single_pass(background_image, model_data, final_size=(520, 728)
|
|
138 |
details_x, details_y = 480, 256
|
139 |
energy_x, energy_y = 480, 472
|
140 |
|
141 |
-
# Text 1 (title)
|
142 |
draw.text((title_x, title_y), str(model_data['model']), font=title_font, fill="black")
|
143 |
draw.text((title_x, title_y + 38), str(model_data['provider']), font=title_font, fill="black")
|
144 |
|
|
|
46 |
|
47 |
st.sidebar.markdown("<hr style='border: 1px solid gray; margin: 15px 0;'>", unsafe_allow_html=True)
|
48 |
|
49 |
+
st.sidebar.write("### Instructions:")
|
50 |
+
st.sidebar.write("#### 1. Select task(s)")
|
51 |
+
|
52 |
+
# Define the ordered list of tasks.
|
53 |
+
task_order = [
|
54 |
+
"Text Generation",
|
55 |
+
"Image Generation",
|
56 |
+
"Text Classification",
|
57 |
+
"Image Classification",
|
58 |
+
"Image Captioning",
|
59 |
+
"Summarization",
|
60 |
+
"ASR",
|
61 |
+
"Object Detection",
|
62 |
+
"Question Answering",
|
63 |
+
"Sentence Similarity"
|
64 |
+
]
|
65 |
+
|
66 |
+
# Multi-select dropdown for tasks.
|
67 |
+
selected_tasks = st.sidebar.multiselect("Select Task(s)", options=task_order, default=task_order)
|
68 |
+
if not selected_tasks:
|
69 |
+
st.sidebar.error("Please select at least one task.")
|
70 |
+
st.stop()
|
71 |
+
|
72 |
+
st.sidebar.write("#### 2. Select a model below")
|
73 |
+
|
74 |
+
# Mapping from task to CSV file name.
|
75 |
+
task_to_file = {
|
76 |
+
"Text Generation": "text_gen_energyscore.csv",
|
77 |
+
"Image Generation": "image_generation_energyscore.csv",
|
78 |
+
"Text Classification": "text_classification_energyscore.csv",
|
79 |
+
"Image Classification": "image_classification_energyscore.csv",
|
80 |
+
"Image Captioning": "image_caption_energyscore.csv",
|
81 |
+
"Summarization": "summarization_energyscore.csv",
|
82 |
+
"ASR": "asr_energyscore.csv",
|
83 |
+
"Object Detection": "object_detection_energyscore.csv",
|
84 |
+
"Question Answering": "question_answering_energyscore.csv",
|
85 |
+
"Sentence Similarity": "sentence_similarity_energyscore.csv"
|
86 |
+
}
|
87 |
+
|
88 |
+
dfs = []
|
89 |
+
# Load and process each CSV corresponding to the selected tasks.
|
90 |
+
for task in selected_tasks:
|
91 |
+
file_name = task_to_file[task]
|
92 |
+
try:
|
93 |
+
df = pd.read_csv(file_name)
|
94 |
+
except FileNotFoundError:
|
95 |
+
st.sidebar.error(f"Could not find '{file_name}' for task {task}!")
|
96 |
+
continue
|
97 |
+
except Exception as e:
|
98 |
+
st.sidebar.error(f"Error reading '{file_name}' for task {task}: {e}")
|
99 |
+
continue
|
100 |
+
|
101 |
+
# Split the "Model" column into 'provider' (before the "/") and 'model' (after the "/")
|
102 |
+
df[['provider', 'model']] = df['Model'].str.split('/', 1, expand=True)
|
103 |
+
# Round total_gpu_energy to 3 decimal places and assign to 'energy'
|
104 |
+
df['energy'] = df['total_gpu_energy'].round(3)
|
105 |
+
# Use the energy_score column as 'score'
|
106 |
+
df['score'] = df['energy_score'].astype(int)
|
107 |
+
# Hardcode date and hardware
|
108 |
+
df['date'] = "February 2025"
|
109 |
+
df['hardware'] = "NVIDIA H100-80GB"
|
110 |
+
# Set the task from the file name mapping
|
111 |
+
df['task'] = task
|
112 |
+
|
113 |
+
dfs.append(df)
|
114 |
+
|
115 |
+
if not dfs:
|
116 |
+
st.sidebar.error("No data available for the selected task(s).")
|
117 |
return
|
118 |
+
|
119 |
+
data_df = pd.concat(dfs, ignore_index=True)
|
120 |
+
|
121 |
+
# Check required columns
|
122 |
required_columns = ["model", "provider", "date", "task", "hardware", "energy", "score"]
|
123 |
for col in required_columns:
|
124 |
if col not in data_df.columns:
|
125 |
st.sidebar.error(f"The CSV file must contain a column named '{col}'.")
|
126 |
return
|
127 |
|
|
|
|
|
|
|
128 |
model_options = data_df["model"].unique().tolist()
|
129 |
selected_model = st.sidebar.selectbox(
|
130 |
"Scored Models",
|
131 |
model_options,
|
132 |
help="Start typing to search for a model"
|
133 |
)
|
134 |
+
|
|
|
135 |
model_data = data_df[data_df["model"] == selected_model].iloc[0]
|
136 |
|
137 |
# Select background by score
|
|
|
196 |
details_x, details_y = 480, 256
|
197 |
energy_x, energy_y = 480, 472
|
198 |
|
199 |
+
# Text 1 (title) - model and provider separated on different lines
|
200 |
draw.text((title_x, title_y), str(model_data['model']), font=title_font, fill="black")
|
201 |
draw.text((title_x, title_y + 38), str(model_data['provider']), font=title_font, fill="black")
|
202 |
|