Skip to content

Commit

Permalink
update comparison workflow intputs
Browse files Browse the repository at this point in the history
  • Loading branch information
almazgimaev committed Nov 11, 2024
1 parent 8e0fccb commit 0c2b5af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/ui/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,18 @@ def run_compare(eval_dirs: List[str] = None):
f.validate_paths(g.eval_dirs)

# ==================== Workflow input ====================
w.workflow_input(g.api, team_files_dirs=g.eval_dirs)
# /model-benchmark/42912_COCO 2017 instance segmentation/67993_Train YOLOv8 | v9 | v10 | v11/visualizations/template.vue
reports = None
try:
reports_paths = [path.rstrip("/") + "/visualizations/template.vue" for path in g.eval_dirs]
reports = [g.api.file.get_info_by_path(g.team_id, path) for path in reports_paths]
except Exception as e:
sly.logger.warning(f"Failed to get model benchmark reports FileInfos: {repr(e)}")

if reports is not None:
w.workflow_input(g.api, model_benchmark_reports=reports)
else:
w.workflow_input(g.api, team_files_dirs=g.eval_dirs)
# =======================================================

comp = ModelComparison(g.api, g.eval_dirs, progress=comp_pbar, workdir=workdir)
Expand Down
10 changes: 10 additions & 0 deletions src/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def workflow_input(
project_info: Optional[sly.ProjectInfo] = None,
session_id: Optional[int] = None,
team_files_dirs: Optional[List[str]] = None,
model_benchmark_reports: Optional[List[sly.api.file_api.FileInfo]] = None,
):
if project_info:
# Create a project version before the task starts
Expand Down Expand Up @@ -52,6 +53,15 @@ def workflow_input(
except Exception as e:
sly.logger.debug(f"Failed to add input to the workflow: {repr(e)}")

if model_benchmark_reports:
# Add input model benchmark reports to the workflow
try:
for model_benchmark_report in model_benchmark_reports:
api.app.workflow.add_input_file(model_benchmark_report)
sly.logger.debug(f"Workflow Input: Model Benchmark Report ID - {model_benchmark_report.id}")
except Exception as e:
sly.logger.debug(f"Failed to add input to the workflow: {repr(e)}")


def workflow_output(
api: sly.Api,
Expand Down

0 comments on commit 0c2b5af

Please sign in to comment.