Skip to content

Commit

Permalink
return result path
Browse files Browse the repository at this point in the history
  • Loading branch information
almazgimaev committed Oct 24, 2024
1 parent f1e370e commit 56082c4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
19 changes: 13 additions & 6 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from fastapi import Request
from fastapi import Request,

import src.globals as g
import supervisely as sly
Expand Down Expand Up @@ -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)}
4 changes: 3 additions & 1 deletion src/ui/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/ui/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 56082c4

Please sign in to comment.