fix(perception): reuse M4.8 for vegetation evidence
This commit is contained in:
@@ -4,11 +4,25 @@ const RESULT_ID = /^lab-v1-vegetation-shadow-[a-f0-9]{64}$/;
|
||||
const SHA256 = /^[a-f0-9]{64}$/;
|
||||
const CANDIDATES = ["ddrnet", "ppliteseg"] as const;
|
||||
const ROUTE_MODES = ["source", "ddrnet", "ppliteseg", "urban", "rural", "offroad"] as const;
|
||||
const VALIDATION_MODES = ["source", "truth", "ddrnet", "ppliteseg"] as const;
|
||||
const VALIDATION_ASSETS = [
|
||||
"source",
|
||||
"truth",
|
||||
"ddrnet",
|
||||
"ppliteseg",
|
||||
"ddrnet_error",
|
||||
"ppliteseg_error",
|
||||
] as const;
|
||||
|
||||
export type VegetationCandidateKey = typeof CANDIDATES[number];
|
||||
export type VegetationRouteMode = typeof ROUTE_MODES[number];
|
||||
export type VegetationValidationMode = typeof VALIDATION_MODES[number];
|
||||
|
||||
export interface VegetationVisualFocus {
|
||||
className: string;
|
||||
labelId: number;
|
||||
truthPixels: number;
|
||||
truthFraction: number;
|
||||
stratumRank: number;
|
||||
}
|
||||
|
||||
export interface VegetationCandidateMetrics {
|
||||
candidate: VegetationCandidateKey;
|
||||
@@ -33,6 +47,7 @@ export interface VegetationVisualCase {
|
||||
height: number;
|
||||
centerCropXyxy: readonly [number, number, number, number];
|
||||
outsideCropState: "undefined" | "not-applicable";
|
||||
focus: VegetationVisualFocus | null;
|
||||
assets: Readonly<Record<string, string>>;
|
||||
}
|
||||
|
||||
@@ -174,7 +189,7 @@ function visualCaseValue(
|
||||
.join("/")}`;
|
||||
}
|
||||
const expectedAssets = expectedKind === "goose"
|
||||
? VALIDATION_MODES
|
||||
? VALIDATION_ASSETS
|
||||
: ROUTE_MODES;
|
||||
if (expectedAssets.some((key) => !projected[key])) {
|
||||
throw new VegetationShadowContractError(`vegetation.case.assets: ${expectedKind} набор неполон.`);
|
||||
@@ -183,6 +198,23 @@ function visualCaseValue(
|
||||
if (outsideCropState !== "undefined" && outsideCropState !== "not-applicable") {
|
||||
throw new VegetationShadowContractError("vegetation.case.outside_crop_state: контракт изменён.");
|
||||
}
|
||||
let focus: VegetationVisualFocus | null = null;
|
||||
if (expectedKind === "goose") {
|
||||
const rawFocus = objectValue(row.focus, "vegetation.case.focus");
|
||||
const truthFraction = numberValue(rawFocus.truth_fraction, "vegetation.case.focus.truth_fraction");
|
||||
if (truthFraction <= 0 || truthFraction > 1) {
|
||||
throw new VegetationShadowContractError("vegetation.case.focus.truth_fraction: диапазон изменён.");
|
||||
}
|
||||
focus = {
|
||||
className: textValue(rawFocus.class_name, "vegetation.case.focus.class_name"),
|
||||
labelId: integerValue(rawFocus.label_id, "vegetation.case.focus.label_id"),
|
||||
truthPixels: integerValue(rawFocus.truth_pixels, "vegetation.case.focus.truth_pixels"),
|
||||
truthFraction,
|
||||
stratumRank: integerValue(rawFocus.stratum_rank, "vegetation.case.focus.stratum_rank"),
|
||||
};
|
||||
} else if (row.focus !== null) {
|
||||
throw new VegetationShadowContractError("vegetation.case.focus: RAVNOVES focus отсутствует.");
|
||||
}
|
||||
return {
|
||||
caseId,
|
||||
sourceKind: expectedKind,
|
||||
@@ -190,6 +222,7 @@ function visualCaseValue(
|
||||
height: integerValue(row.height, "vegetation.case.height"),
|
||||
centerCropXyxy: crop as unknown as readonly [number, number, number, number],
|
||||
outsideCropState,
|
||||
focus,
|
||||
assets: projected,
|
||||
};
|
||||
}
|
||||
@@ -233,8 +266,8 @@ function parseResult(value: unknown, resultId: string): VegetationShadowResult {
|
||||
.map((item) => visualCaseValue(item, resultId, "ravnoves"));
|
||||
const validationCases = arrayValue(catalogs.goose, "vegetation.catalogs.goose")
|
||||
.map((item) => visualCaseValue(item, resultId, "goose"));
|
||||
if (routeCases.length !== 12 || validationCases.length !== 12) {
|
||||
throw new VegetationShadowContractError("vegetation.catalogs: ожидалось 12 + 12 случаев.");
|
||||
if (routeCases.length !== 0 || validationCases.length !== 12) {
|
||||
throw new VegetationShadowContractError("vegetation.catalogs: ожидалось 12 truth-backed GOOSE случаев без route viewer.");
|
||||
}
|
||||
return {
|
||||
resultId,
|
||||
|
||||
Reference in New Issue
Block a user