Spaces:
Sleeping
Sleeping
change every username to be modelname
Browse files
app.py
CHANGED
|
@@ -42,7 +42,7 @@ def fetch_required_files(exp_config):
|
|
| 42 |
return exp_config
|
| 43 |
|
| 44 |
|
| 45 |
-
def call_flask_server(
|
| 46 |
url = "https://saraht14-server.hf.space/"
|
| 47 |
|
| 48 |
try:
|
|
@@ -241,15 +241,15 @@ def read_configuration(filename):
|
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
-
def evaluate_model(
|
| 245 |
print("evaluating...")
|
| 246 |
global leaderboard_data
|
| 247 |
|
| 248 |
-
|
| 249 |
-
if not
|
| 250 |
return leaderboard_data.values.tolist()
|
| 251 |
|
| 252 |
-
script_path = f"submissions/{
|
| 253 |
os.makedirs("submissions", exist_ok=True)
|
| 254 |
|
| 255 |
# # Get the file path from the NamedString object
|
|
@@ -334,12 +334,12 @@ def evaluate_model(username, file):
|
|
| 334 |
status = "Success" if accuracy > 0 else "Incorrect Model"
|
| 335 |
# ["Username", "Execution Time (s)", "Accuracy", "True Positive", "False Positive", "False Negative", "False Positive"]
|
| 336 |
except Exception as e:
|
| 337 |
-
leaderboard_data = pd.concat([leaderboard_data, pd.DataFrame([[
|
| 338 |
columns=HEADERS)], ignore_index=True)
|
| 339 |
return leaderboard_data.values.tolist()
|
| 340 |
print("calculating new entry")
|
| 341 |
|
| 342 |
-
new_entry = pd.DataFrame([[
|
| 343 |
columns=HEADERS)
|
| 344 |
print("updating new entry")
|
| 345 |
leaderboard_data = update_results_dataset(new_entry)
|
|
@@ -424,13 +424,13 @@ def import_and_run_function(script_path, function_name, filename):
|
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
-
def update_leaderboard(
|
| 428 |
if not zip_file:
|
| 429 |
set_error_message("No file uploaded.")
|
| 430 |
return get_error_message(), None
|
| 431 |
|
| 432 |
zip_path = zip_file.name
|
| 433 |
-
extract_path = os.path.join("",
|
| 434 |
# if not os.path.exists(extract_path):
|
| 435 |
# os.makedirs(extract_path)
|
| 436 |
|
|
@@ -489,7 +489,7 @@ def update_leaderboard(username, zip_file):
|
|
| 489 |
return "No Python script (main.py) found in ZIP.", None
|
| 490 |
|
| 491 |
try:
|
| 492 |
-
updated_leaderboard = evaluate_model(
|
| 493 |
|
| 494 |
if updated_leaderboard == None:
|
| 495 |
return "An error occured while evaluting the model", None
|
|
@@ -511,7 +511,7 @@ with gr.Blocks() as demo:
|
|
| 511 |
gr.Markdown("# 🚀 Indoor vs Outdoor Detection Leaderboard \nUsing the provided dataset, submit a model that can predict if a device is inside or outside. \nSee the README for submission details.")
|
| 512 |
|
| 513 |
with gr.Row():
|
| 514 |
-
|
| 515 |
file_input = gr.File(label="Upload Zip File")
|
| 516 |
submit_button = gr.Button("Submit File")
|
| 517 |
|
|
@@ -526,7 +526,7 @@ with gr.Blocks() as demo:
|
|
| 526 |
|
| 527 |
|
| 528 |
submit_button.click(fn=update_leaderboard,
|
| 529 |
-
inputs=[
|
| 530 |
outputs=[status_output, leaderboard_display])
|
| 531 |
|
| 532 |
status_output.change(fn=get_error_message, inputs=[], outputs=status_output)
|
|
|
|
| 42 |
return exp_config
|
| 43 |
|
| 44 |
|
| 45 |
+
def call_flask_server(modelname):
|
| 46 |
url = "https://saraht14-server.hf.space/"
|
| 47 |
|
| 48 |
try:
|
|
|
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
+
def evaluate_model(modelname, file):
|
| 245 |
print("evaluating...")
|
| 246 |
global leaderboard_data
|
| 247 |
|
| 248 |
+
modelname = modelname.strip()
|
| 249 |
+
if not modelname:
|
| 250 |
return leaderboard_data.values.tolist()
|
| 251 |
|
| 252 |
+
script_path = f"submissions/{modelname}.py"
|
| 253 |
os.makedirs("submissions", exist_ok=True)
|
| 254 |
|
| 255 |
# # Get the file path from the NamedString object
|
|
|
|
| 334 |
status = "Success" if accuracy > 0 else "Incorrect Model"
|
| 335 |
# ["Username", "Execution Time (s)", "Accuracy", "True Positive", "False Positive", "False Negative", "False Positive"]
|
| 336 |
except Exception as e:
|
| 337 |
+
leaderboard_data = pd.concat([leaderboard_data, pd.DataFrame([[modelname, float("inf"), 0,-1,-1,-1,-1]],
|
| 338 |
columns=HEADERS)], ignore_index=True)
|
| 339 |
return leaderboard_data.values.tolist()
|
| 340 |
print("calculating new entry")
|
| 341 |
|
| 342 |
+
new_entry = pd.DataFrame([[modelname, execution_time, accuracy, TP, FP, FN, TN]],
|
| 343 |
columns=HEADERS)
|
| 344 |
print("updating new entry")
|
| 345 |
leaderboard_data = update_results_dataset(new_entry)
|
|
|
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
+
def update_leaderboard(modelname, zip_file):
|
| 428 |
if not zip_file:
|
| 429 |
set_error_message("No file uploaded.")
|
| 430 |
return get_error_message(), None
|
| 431 |
|
| 432 |
zip_path = zip_file.name
|
| 433 |
+
extract_path = os.path.join("", modelname)
|
| 434 |
# if not os.path.exists(extract_path):
|
| 435 |
# os.makedirs(extract_path)
|
| 436 |
|
|
|
|
| 489 |
return "No Python script (main.py) found in ZIP.", None
|
| 490 |
|
| 491 |
try:
|
| 492 |
+
updated_leaderboard = evaluate_model(modelname, python_script)
|
| 493 |
|
| 494 |
if updated_leaderboard == None:
|
| 495 |
return "An error occured while evaluting the model", None
|
|
|
|
| 511 |
gr.Markdown("# 🚀 Indoor vs Outdoor Detection Leaderboard \nUsing the provided dataset, submit a model that can predict if a device is inside or outside. \nSee the README for submission details.")
|
| 512 |
|
| 513 |
with gr.Row():
|
| 514 |
+
modelname_input = gr.Textbox(label="Model Name")
|
| 515 |
file_input = gr.File(label="Upload Zip File")
|
| 516 |
submit_button = gr.Button("Submit File")
|
| 517 |
|
|
|
|
| 526 |
|
| 527 |
|
| 528 |
submit_button.click(fn=update_leaderboard,
|
| 529 |
+
inputs=[modelname_input, file_input],
|
| 530 |
outputs=[status_output, leaderboard_display])
|
| 531 |
|
| 532 |
status_output.change(fn=get_error_message, inputs=[], outputs=status_output)
|