Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
7738e98
1
Parent(s):
293e470
Enhance model submission function to include task parameter and update evaluation checks
Browse files
utils.py
CHANGED
@@ -44,11 +44,11 @@ def fetch_model_information(model_name):
|
|
44 |
return
|
45 |
return gr.update(choices=supported_precisions, value=supported_precisions[0]), num_parameters, license
|
46 |
|
47 |
-
def submit_model(model_name, revision, precision, params, license):
|
48 |
# Load existing evaluations
|
49 |
df_retrieval = load_retrieval_results()
|
50 |
|
51 |
-
existing_models_results = df_retrieval[['Model', 'Revision', 'Precision']]
|
52 |
|
53 |
# Handle 'Missing' precision
|
54 |
if precision == 'Missing':
|
@@ -63,33 +63,37 @@ def submit_model(model_name, revision, precision, params, license):
|
|
63 |
# Check if model is already evaluated
|
64 |
model_exists_in_results = ((existing_models_results['Model'] == model_name) &
|
65 |
(existing_models_results['Revision'] == revision) &
|
66 |
-
(existing_models_results['Precision'] == precision)
|
|
|
67 |
if model_exists_in_results:
|
68 |
-
return f"
|
69 |
|
70 |
# Check if model is in pending requests
|
71 |
if not df_pending.empty:
|
72 |
existing_models_pending = df_pending[['model_name', 'revision', 'precision']]
|
73 |
model_exists_in_pending = ((existing_models_pending['model_name'] == model_name) &
|
74 |
(existing_models_pending['revision'] == revision) &
|
75 |
-
(existing_models_pending['precision'] == precision)
|
|
|
76 |
if model_exists_in_pending:
|
77 |
-
return f"
|
78 |
|
79 |
# Check if model is in finished requests
|
80 |
if not df_finished.empty:
|
81 |
existing_models_finished = df_finished[['model_name', 'revision', 'precision']]
|
82 |
model_exists_in_finished = ((existing_models_finished['model_name'] == model_name) &
|
83 |
(existing_models_finished['revision'] == revision) &
|
84 |
-
(existing_models_finished['precision'] == precision)
|
|
|
85 |
if model_exists_in_finished:
|
86 |
-
return f"
|
87 |
|
88 |
# Check if model exists on HuggingFace Hub
|
89 |
try:
|
90 |
api.model_info(model_name)
|
91 |
except Exception as e:
|
92 |
-
|
|
|
93 |
|
94 |
# Proceed with submission
|
95 |
status = "PENDING"
|
@@ -173,7 +177,6 @@ def load_requests(status_folder):
|
|
173 |
|
174 |
|
175 |
def submit_gradio_module(type):
|
176 |
-
|
177 |
with gr.Tab(f"Submit {type}") as submitter_tab:
|
178 |
with gr.Row(equal_height=True):
|
179 |
model_name_input = gr.Textbox(
|
|
|
44 |
return
|
45 |
return gr.update(choices=supported_precisions, value=supported_precisions[0]), num_parameters, license
|
46 |
|
47 |
+
def submit_model(model_name, revision, precision, params, license, task):
|
48 |
# Load existing evaluations
|
49 |
df_retrieval = load_retrieval_results()
|
50 |
|
51 |
+
existing_models_results = df_retrieval[['Model', 'Revision', 'Precision', "Task"]]
|
52 |
|
53 |
# Handle 'Missing' precision
|
54 |
if precision == 'Missing':
|
|
|
63 |
# Check if model is already evaluated
|
64 |
model_exists_in_results = ((existing_models_results['Model'] == model_name) &
|
65 |
(existing_models_results['Revision'] == revision) &
|
66 |
+
(existing_models_results['Precision'] == precision) &
|
67 |
+
(existing_models_results['Task'] == task)).any()
|
68 |
if model_exists_in_results:
|
69 |
+
return gr.Info(f"Model '{model_name}' with revision '{revision}' and precision '{precision}' for task '{task}' has already been evaluated.")
|
70 |
|
71 |
# Check if model is in pending requests
|
72 |
if not df_pending.empty:
|
73 |
existing_models_pending = df_pending[['model_name', 'revision', 'precision']]
|
74 |
model_exists_in_pending = ((existing_models_pending['model_name'] == model_name) &
|
75 |
(existing_models_pending['revision'] == revision) &
|
76 |
+
(existing_models_pending['precision'] == precision) &
|
77 |
+
(existing_models_pending['task'] == task)).any()
|
78 |
if model_exists_in_pending:
|
79 |
+
return gr.Info(f"Model '{model_name}' with revision '{revision}' and precision '{precision}' for task '{task}' is already in the evaluation queue.")
|
80 |
|
81 |
# Check if model is in finished requests
|
82 |
if not df_finished.empty:
|
83 |
existing_models_finished = df_finished[['model_name', 'revision', 'precision']]
|
84 |
model_exists_in_finished = ((existing_models_finished['model_name'] == model_name) &
|
85 |
(existing_models_finished['revision'] == revision) &
|
86 |
+
(existing_models_finished['precision'] == precision) &
|
87 |
+
(existing_models_finished['task'] == task)).any()
|
88 |
if model_exists_in_finished:
|
89 |
+
return gr.Info(f"Model '{model_name}' with revision '{revision}' and precision '{precision}' for task '{task}' has already been evaluated.")
|
90 |
|
91 |
# Check if model exists on HuggingFace Hub
|
92 |
try:
|
93 |
api.model_info(model_name)
|
94 |
except Exception as e:
|
95 |
+
print(f"Error fetching model info: {e}")
|
96 |
+
return gr.Error(f"**Error: Model '{model_name}' not found on HuggingFace Hub.**")
|
97 |
|
98 |
# Proceed with submission
|
99 |
status = "PENDING"
|
|
|
177 |
|
178 |
|
179 |
def submit_gradio_module(type):
|
|
|
180 |
with gr.Tab(f"Submit {type}") as submitter_tab:
|
181 |
with gr.Row(equal_height=True):
|
182 |
model_name_input = gr.Textbox(
|