Validate uploaded YOLO custom workflow
This commit is contained in:
@@ -267,6 +267,19 @@ def _write_acceptance_images(root: Path) -> tuple[Path, Path, Path]:
|
||||
return image_path, label_path, result_dir
|
||||
|
||||
|
||||
def _relative_to_project(path: Path) -> str:
|
||||
try:
|
||||
return str(path.resolve().relative_to(settings.project_root))
|
||||
except ValueError:
|
||||
return str(path.resolve())
|
||||
|
||||
|
||||
def _result_files(root: Path, suffixes: set[str]) -> list[Path]:
|
||||
if not root.exists():
|
||||
return []
|
||||
return sorted(path for path in root.rglob("*") if path.is_file() and path.suffix.lower() in suffixes)
|
||||
|
||||
|
||||
def run_model_family_readiness() -> dict[str, Any]:
|
||||
"""Exercise the model-family runtime stack without launching full training."""
|
||||
source = settings.source_root
|
||||
@@ -501,6 +514,61 @@ def run_live_acceptance(base_url: str = "http://127.0.0.1:8010") -> dict[str, An
|
||||
}
|
||||
)
|
||||
|
||||
yolo_weight = settings.source_root / "Seg_All_In_One_YoloModel" / "yolo11n-seg.pt"
|
||||
uploaded_image_source = settings.project_root / "var" / "uploads" / "datasets" / dataset_name / "images"
|
||||
predict_name = f"{dataset_name}_predict_smoke"
|
||||
predict = _create_job_and_wait(
|
||||
base_url,
|
||||
"yolo.predict_custom",
|
||||
{
|
||||
"weights": str(yolo_weight),
|
||||
"source": _relative_to_project(uploaded_image_source),
|
||||
"project": "var/custom_yolo_runs",
|
||||
"name": predict_name,
|
||||
"imgsz": 64,
|
||||
"conf": 0.05,
|
||||
"device": "cpu",
|
||||
"exist_ok": True,
|
||||
},
|
||||
timeout=120,
|
||||
)
|
||||
predict_root = settings.project_root / "var" / "custom_yolo_runs" / predict_name
|
||||
predict_outputs = _result_files(predict_root, {".png", ".jpg", ".jpeg"})
|
||||
checks.append(
|
||||
{
|
||||
"name": "uploaded_yolo_predict_job_runner",
|
||||
"passed": predict.get("passed", False) and bool(predict_outputs),
|
||||
"detail": {**predict, "output_count": len(predict_outputs), "outputs": [_relative_to_project(path) for path in predict_outputs[:8]]},
|
||||
}
|
||||
)
|
||||
|
||||
heatmap_name = f"{dataset_name}_heatmap_smoke"
|
||||
heatmap = _create_job_and_wait(
|
||||
base_url,
|
||||
"yolo.heatmap_custom",
|
||||
{
|
||||
"weights": str(yolo_weight),
|
||||
"source": _relative_to_project(uploaded_image_source),
|
||||
"project": "var/custom_yolo_runs",
|
||||
"name": heatmap_name,
|
||||
"model_key": "YOLO11n-seg",
|
||||
"pt_name": "best.pt",
|
||||
"cam_method": "GradCAM",
|
||||
"target_layers": "model.model.model[9]",
|
||||
"limit": 1,
|
||||
},
|
||||
timeout=120,
|
||||
)
|
||||
heatmap_root = settings.project_root / "var" / "custom_yolo_runs" / heatmap_name / "HeartMap_Visual"
|
||||
heatmap_outputs = _result_files(heatmap_root, {".jpg", ".jpeg", ".png"})
|
||||
checks.append(
|
||||
{
|
||||
"name": "uploaded_yolo_heatmap_job_runner",
|
||||
"passed": heatmap.get("passed", False) and len(heatmap_outputs) >= 2,
|
||||
"detail": {**heatmap, "output_count": len(heatmap_outputs), "outputs": [_relative_to_project(path) for path in heatmap_outputs[:8]]},
|
||||
}
|
||||
)
|
||||
|
||||
mock = _create_job_and_wait(base_url, "mock.echo", {"message": f"acceptance {run_id}"}, timeout=45)
|
||||
mock_log = mock.get("polled", {}).get("job", {}).get("log_tail", "")
|
||||
checks.append({"name": "mock_job_runner", "passed": mock.get("passed", False) and f"acceptance {run_id}" in mock_log, "detail": mock})
|
||||
|
||||
Reference in New Issue
Block a user