diff --git a/src/main.py b/src/main.py index 430505e..06d81a6 100644 --- a/src/main.py +++ b/src/main.py @@ -1,4 +1,4 @@ -from fastapi import Request +from fastapi import Request, import src.globals as g import supervisely as sly @@ -39,13 +39,20 @@ def start_comparison(): @server.post("/run_evaluation") async def evaluate(request: Request): req = await request.json() - state = req["state"] - run_evaluation(state["session_id"], state["project_id"]) + try: + state = req["state"] + run_evaluation(state["session_id"], state["project_id"]) + except Exception as e: + sly.logger.error(f"Error during model evaluation: {e}") + return {"error": str(e)} @server.post("/run_comparison") async def compare(request: Request): req = await request.json() - print(req) - state = req["state"] - run_compare(state["eval_dirs"]) + try: + state = req["state"] + return run_compare(state["eval_dirs"]) + except Exception as e: + sly.logger.error(f"Error during model comparison: {e}") + return {"error": str(e)} diff --git a/src/ui/compare.py b/src/ui/compare.py index 943b390..8b19862 100644 --- a/src/ui/compare.py +++ b/src/ui/compare.py @@ -24,7 +24,7 @@ def run_compare(eval_dirs: List[str] = None): comp = ModelComparison(g.api, g.eval_dirs, progress=pbar, workdir=workdir) comp.visualize() res_dir = f.get_res_dir(g.eval_dirs) - comp.upload_results(g.team_id, remote_dir=res_dir, progress=pbar) + res_dir = comp.upload_results(g.team_id, remote_dir=res_dir, progress=pbar) report = g.api.file.get_info_by_path(g.team_id, comp.get_report_link()) g.api.task.set_output_report(g.task_id, report.id, report.name) @@ -40,6 +40,8 @@ def run_compare(eval_dirs: List[str] = None): compare_button.loading = False + return res_dir + compare_button = widgets.Button("Compare") pbar = widgets.SlyTqdm() diff --git a/src/ui/evaluation.py b/src/ui/evaluation.py index e29067d..274e98a 100644 --- a/src/ui/evaluation.py +++ b/src/ui/evaluation.py @@ -142,6 +142,8 @@ def run_evaluation( eval_button.loading = False + return res_dir + no_classes_label = widgets.Text( "Not found any classes in the project that are present in the model", status="error"