Spaces:
Sleeping
Sleeping
check if still works
Browse files
app.py
CHANGED
|
@@ -42,18 +42,6 @@ def fetch_required_files(exp_config):
|
|
| 42 |
return exp_config
|
| 43 |
|
| 44 |
|
| 45 |
-
def call_flask_server(username):
|
| 46 |
-
url = "https://saraht14-server.hf.space/"
|
| 47 |
-
|
| 48 |
-
try:
|
| 49 |
-
response = requests.get(url)
|
| 50 |
-
result = response.json()
|
| 51 |
-
print("Flask response:", result)
|
| 52 |
-
return result.get("result", "No result")
|
| 53 |
-
except Exception as e:
|
| 54 |
-
print("Failed to contact Flask server:", e)
|
| 55 |
-
return f"Error contacting server: {e}"
|
| 56 |
-
call_flask_server("sarah")
|
| 57 |
def download_file(url, local_path):
|
| 58 |
try:
|
| 59 |
r = requests.get(url, headers={"Authorization": f"Bearer {HF_TOKEN}"})
|
|
@@ -251,20 +239,6 @@ def evaluate_model(username, groupname, file):
|
|
| 251 |
|
| 252 |
script_path = f"submissions/{username}.py"
|
| 253 |
os.makedirs("submissions", exist_ok=True)
|
| 254 |
-
|
| 255 |
-
# # Get the file path from the NamedString object
|
| 256 |
-
# file_path = file.name # Get the actual file path
|
| 257 |
-
# print("file_path:", file_path)
|
| 258 |
-
# with open(script_path, "wb") as f:
|
| 259 |
-
# with open(file_path, "rb") as uploaded_file:
|
| 260 |
-
# f.write(uploaded_file.read())
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
# script_path = f"submissions/{username}.py"
|
| 265 |
-
# os.makedirs("submissions", exist_ok=True)
|
| 266 |
-
# with open(script_path, "wb") as f:
|
| 267 |
-
# f.write(file.read())
|
| 268 |
|
| 269 |
try:
|
| 270 |
|
|
@@ -286,25 +260,13 @@ def evaluate_model(username, groupname, file):
|
|
| 286 |
# print(file_path)
|
| 287 |
filename = filename + ".txt"
|
| 288 |
print("FILE TO PROCESS:", filename)
|
| 289 |
-
# filename_url = f"https://saraht14-server.hf.space/file/{filename}"
|
| 290 |
-
# local_txt_path = f"./{filename}.txt"
|
| 291 |
-
# os.makedirs("temp_data", exist_ok=True)
|
| 292 |
-
# local_file_path = exp[key]["local_file"]
|
| 293 |
-
# downloaded = download_file(filename_url, local_txt_path)
|
| 294 |
local_file_path = hf_hub_download(repo_id="IndoorOutdoor/metadata",
|
| 295 |
filename=filename,
|
| 296 |
repo_type="dataset",
|
| 297 |
token=READ_TOKEN)
|
| 298 |
-
# if not downloaded:
|
| 299 |
-
# raise Exception("Failed to fetch remote file.")
|
| 300 |
-
# sectors_model = subprocess.run(["python", script_path,filename], capture_output=True, text=True, timeout=300)
|
| 301 |
-
# hello = foo()
|
| 302 |
-
# print(f"HELLO: {hello}")
|
| 303 |
-
# import
|
| 304 |
sectors_model = import_and_run_function(file, "evaluate", local_file_path)
|
| 305 |
if sectors_model == None:
|
| 306 |
return None
|
| 307 |
-
|
| 308 |
try:
|
| 309 |
os.remove(local_file_path)
|
| 310 |
except Exception as e:
|
|
@@ -314,9 +276,6 @@ def evaluate_model(username, groupname, file):
|
|
| 314 |
|
| 315 |
|
| 316 |
print("SECTORS MODEL: ", sectors_model)
|
| 317 |
-
# sectors_model = eval(filename)
|
| 318 |
-
# print(sectors_model)
|
| 319 |
-
# sectors_model = model_based_clustering(dataset_directory, filename)
|
| 320 |
|
| 321 |
stats_model_sectors.append(compute_stats_sector(sectors_model, sectors_gt))
|
| 322 |
stats_model_in_out.append(compute_stats_in_out(sectors_model, indoor_gt))
|
|
|
|
| 42 |
return exp_config
|
| 43 |
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
def download_file(url, local_path):
|
| 46 |
try:
|
| 47 |
r = requests.get(url, headers={"Authorization": f"Bearer {HF_TOKEN}"})
|
|
|
|
| 239 |
|
| 240 |
script_path = f"submissions/{username}.py"
|
| 241 |
os.makedirs("submissions", exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
|
| 243 |
try:
|
| 244 |
|
|
|
|
| 260 |
# print(file_path)
|
| 261 |
filename = filename + ".txt"
|
| 262 |
print("FILE TO PROCESS:", filename)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
local_file_path = hf_hub_download(repo_id="IndoorOutdoor/metadata",
|
| 264 |
filename=filename,
|
| 265 |
repo_type="dataset",
|
| 266 |
token=READ_TOKEN)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
sectors_model = import_and_run_function(file, "evaluate", local_file_path)
|
| 268 |
if sectors_model == None:
|
| 269 |
return None
|
|
|
|
| 270 |
try:
|
| 271 |
os.remove(local_file_path)
|
| 272 |
except Exception as e:
|
|
|
|
| 276 |
|
| 277 |
|
| 278 |
print("SECTORS MODEL: ", sectors_model)
|
|
|
|
|
|
|
|
|
|
| 279 |
|
| 280 |
stats_model_sectors.append(compute_stats_sector(sectors_model, sectors_gt))
|
| 281 |
stats_model_in_out.append(compute_stats_in_out(sectors_model, indoor_gt))
|