237 const YAML::Node root = YAML::LoadFile(path);
238 EnsureKnownKeys(root,
"root", {
"schema_version",
"artifact",
"frozen_contract",
"runtime_defaults"});
240 const YAML::Node artifact = RequireChild(root,
"artifact",
"artifact");
241 EnsureKnownKeys(artifact,
"artifact",
242 {
"bundle_name",
"export_format",
"backend",
"precision",
"device",
"head_name",
"export_timestamp_utc",
243 "files",
"triton",
"inputs",
"outputs",
"size_priors",
"size_priors_source"});
245 const YAML::Node files = RequireChild(artifact,
"files",
"artifact.files");
246 EnsureKnownKeys(files,
"artifact.files",
247 {
"model",
"checkpoint",
"resolved_training_config",
"triton_repository",
"triton_config",
"triton_model"});
249 const YAML::Node triton = RequireChild(artifact,
"triton",
"artifact.triton");
250 EnsureKnownKeys(triton,
"artifact.triton", {
"enabled",
"model_name",
"model_version"});
252 const YAML::Node inputs = RequireChild(artifact,
"inputs",
"artifact.inputs");
253 const YAML::Node outputs = RequireChild(artifact,
"outputs",
"artifact.outputs");
255 const YAML::Node frozen_contract = RequireChild(root,
"frozen_contract",
"frozen_contract");
256 EnsureKnownKeys(frozen_contract,
"frozen_contract", {
"preprocessing",
"postprocessing",
"model"});
258 const YAML::Node preprocessing = RequireChild(frozen_contract,
"preprocessing",
"frozen_contract.preprocessing");
259 EnsureKnownKeys(preprocessing,
"frozen_contract.preprocessing",
260 {
"max_num_points",
"num_point_features",
"point_cloud_range",
"voxel_size",
"point_feature_normalization"});
262 const YAML::Node point_cloud_range =
263 RequireChild(preprocessing,
"point_cloud_range",
"frozen_contract.preprocessing.point_cloud_range");
264 EnsureKnownKeys(point_cloud_range,
"frozen_contract.preprocessing.point_cloud_range", {
"x",
"y",
"z"});
266 const YAML::Node voxel_size = RequireChild(preprocessing,
"voxel_size",
"frozen_contract.preprocessing.voxel_size");
267 EnsureKnownKeys(voxel_size,
"frozen_contract.preprocessing.voxel_size", {
"x",
"y",
"z"});
269 const YAML::Node normalization =
270 RequireChild(preprocessing,
"point_feature_normalization",
"frozen_contract.preprocessing.point_feature_normalization");
271 EnsureKnownKeys(normalization,
"frozen_contract.preprocessing.point_feature_normalization",
272 {
"type",
"min_value",
"max_value",
"epsilon"});
274 const YAML::Node postprocessing = RequireChild(frozen_contract,
"postprocessing",
"frozen_contract.postprocessing");
275 EnsureKnownKeys(postprocessing,
"frozen_contract.postprocessing", {
"grid_size",
"num_classes",
"class_names"});
277 const YAML::Node grid_size = RequireChild(postprocessing,
"grid_size",
"frozen_contract.postprocessing.grid_size");
278 EnsureKnownKeys(grid_size,
"frozen_contract.postprocessing.grid_size", {
"x",
"y"});
280 const YAML::Node model = RequireChild(frozen_contract,
"model",
"frozen_contract.model");
281 EnsureKnownKeys(model,
"frozen_contract.model",
282 {
"stride",
"up_stride",
"first_up_stride",
"pillar_map_size",
"pillar_map_range"});
284 const YAML::Node runtime_defaults = RequireChild(root,
"runtime_defaults",
"runtime_defaults");
285 EnsureKnownKeys(runtime_defaults,
"runtime_defaults", {
"preprocessing",
"postprocessing"});
287 const YAML::Node runtime_preprocessing = RequireChild(runtime_defaults,
"preprocessing",
"runtime_defaults.preprocessing");
288 EnsureKnownKeys(runtime_preprocessing,
"runtime_defaults.preprocessing", {
"point_feature"});
290 const YAML::Node point_feature =
291 RequireChild(runtime_preprocessing,
"point_feature",
"runtime_defaults.preprocessing.point_feature");
292 EnsureKnownKeys(point_feature,
"runtime_defaults.preprocessing.point_feature", {
"value_threshold"});
294 const YAML::Node runtime_postprocessing = RequireChild(runtime_defaults,
"postprocessing",
"runtime_defaults.postprocessing");
295 EnsureKnownKeys(runtime_postprocessing,
"runtime_defaults.postprocessing", {
"class_score_threshold",
"nms"});
297 const YAML::Node nms = RequireChild(runtime_postprocessing,
"nms",
"runtime_defaults.postprocessing.nms");
298 EnsureKnownKeys(nms,
"runtime_defaults.postprocessing.nms", {
"score_threshold",
"iou_threshold",
"max_num_objects"});
302 manifest.
schema_version = RequireScalarText(RequireChild(root,
"schema_version",
"schema_version"),
"schema_version");
304 manifest.artifact.bundle_name =
305 RequireScalarText(RequireChild(artifact,
"bundle_name",
"artifact.bundle_name"),
"artifact.bundle_name");
306 manifest.artifact.export_format =
307 RequireScalarText(RequireChild(artifact,
"export_format",
"artifact.export_format"),
"artifact.export_format");
308 manifest.artifact.backend = RequireScalarText(RequireChild(artifact,
"backend",
"artifact.backend"),
"artifact.backend");
309 manifest.artifact.precision =
310 RequireScalarText(RequireChild(artifact,
"precision",
"artifact.precision"),
"artifact.precision");
311 manifest.artifact.device = RequireScalarText(RequireChild(artifact,
"device",
"artifact.device"),
"artifact.device");
312 manifest.artifact.head_name = LoadOptionalText(LoadOptionalChild(artifact,
"head_name"),
"artifact.head_name");
313 manifest.artifact.export_timestamp_utc =
314 LoadOptionalText(LoadOptionalChild(artifact,
"export_timestamp_utc"),
"artifact.export_timestamp_utc");
316 manifest.artifact.files.model = LoadOptionalText(LoadOptionalChild(files,
"model"),
"artifact.files.model");
317 manifest.artifact.files.checkpoint =
318 RequireScalarText(RequireChild(files,
"checkpoint",
"artifact.files.checkpoint"),
"artifact.files.checkpoint");
319 manifest.artifact.files.resolved_training_config =
320 RequireScalarText(RequireChild(files,
"resolved_training_config",
"artifact.files.resolved_training_config"),
321 "artifact.files.resolved_training_config");
322 manifest.artifact.files.triton_repository =
323 LoadOptionalText(LoadOptionalChild(files,
"triton_repository"),
"artifact.files.triton_repository");
324 manifest.artifact.files.triton_config =
325 LoadOptionalText(LoadOptionalChild(files,
"triton_config"),
"artifact.files.triton_config");
326 manifest.artifact.files.triton_model =
327 LoadOptionalText(LoadOptionalChild(files,
"triton_model"),
"artifact.files.triton_model");
329 manifest.artifact.triton.enabled =
330 RequireScalarValue<bool>(RequireChild(triton,
"enabled",
"artifact.triton.enabled"),
"artifact.triton.enabled");
331 manifest.artifact.triton.model_name = LoadOptionalText(LoadOptionalChild(triton,
"model_name"),
"artifact.triton.model_name");
332 manifest.artifact.triton.model_version =
333 LoadOptionalText(LoadOptionalChild(triton,
"model_version"),
"artifact.triton.model_version");
335 manifest.artifact.inputs = RequireTensorList(inputs,
"artifact.inputs");
336 manifest.artifact.outputs = RequireTensorList(outputs,
"artifact.outputs");
337 manifest.artifact.size_priors = LoadOptionalSizePriors(LoadOptionalChild(artifact,
"size_priors"),
"artifact.size_priors");
338 manifest.artifact.size_priors_source =
339 LoadOptionalText(LoadOptionalChild(artifact,
"size_priors_source"),
"artifact.size_priors_source");
341 manifest.frozen_contract.preprocessing.max_num_points =
342 RequireScalarValue<int>(RequireChild(preprocessing,
"max_num_points",
"frozen_contract.preprocessing.max_num_points"),
343 "frozen_contract.preprocessing.max_num_points");
344 manifest.frozen_contract.preprocessing.num_point_features = RequireScalarValue<int>(
345 RequireChild(preprocessing,
"num_point_features",
"frozen_contract.preprocessing.num_point_features"),
346 "frozen_contract.preprocessing.num_point_features");
347 manifest.frozen_contract.preprocessing.x_range =
348 RequireRange2(RequireChild(point_cloud_range,
"x",
"frozen_contract.preprocessing.point_cloud_range.x"),
349 "frozen_contract.preprocessing.point_cloud_range.x");
350 manifest.frozen_contract.preprocessing.y_range =
351 RequireRange2(RequireChild(point_cloud_range,
"y",
"frozen_contract.preprocessing.point_cloud_range.y"),
352 "frozen_contract.preprocessing.point_cloud_range.y");
353 manifest.frozen_contract.preprocessing.z_range =
354 RequireRange2(RequireChild(point_cloud_range,
"z",
"frozen_contract.preprocessing.point_cloud_range.z"),
355 "frozen_contract.preprocessing.point_cloud_range.z");
356 manifest.frozen_contract.preprocessing.voxel_x =
357 RequireScalarValue<float>(RequireChild(voxel_size,
"x",
"frozen_contract.preprocessing.voxel_size.x"),
358 "frozen_contract.preprocessing.voxel_size.x");
359 manifest.frozen_contract.preprocessing.voxel_y =
360 RequireScalarValue<float>(RequireChild(voxel_size,
"y",
"frozen_contract.preprocessing.voxel_size.y"),
361 "frozen_contract.preprocessing.voxel_size.y");
362 manifest.frozen_contract.preprocessing.voxel_z =
363 RequireScalarValue<float>(RequireChild(voxel_size,
"z",
"frozen_contract.preprocessing.voxel_size.z"),
364 "frozen_contract.preprocessing.voxel_size.z");
365 manifest.frozen_contract.preprocessing.point_feature_normalization.type =
366 RequireScalarText(RequireChild(normalization,
"type",
"frozen_contract.preprocessing.point_feature_normalization.type"),
367 "frozen_contract.preprocessing.point_feature_normalization.type");
368 manifest.frozen_contract.preprocessing.point_feature_normalization.epsilon = RequireScalarValue<float>(
369 RequireChild(normalization,
"epsilon",
"frozen_contract.preprocessing.point_feature_normalization.epsilon"),
370 "frozen_contract.preprocessing.point_feature_normalization.epsilon");
371 if (manifest.frozen_contract.preprocessing.point_feature_normalization.type ==
"min_max") {
372 manifest.frozen_contract.preprocessing.point_feature_normalization.min_value = RequireScalarValue<float>(
373 RequireChild(normalization,
"min_value",
"frozen_contract.preprocessing.point_feature_normalization.min_value"),
374 "frozen_contract.preprocessing.point_feature_normalization.min_value");
375 manifest.frozen_contract.preprocessing.point_feature_normalization.max_value = RequireScalarValue<float>(
376 RequireChild(normalization,
"max_value",
"frozen_contract.preprocessing.point_feature_normalization.max_value"),
377 "frozen_contract.preprocessing.point_feature_normalization.max_value");
380 manifest.frozen_contract.postprocessing.grid_x = RequireScalarValue<int>(
381 RequireChild(grid_size,
"x",
"frozen_contract.postprocessing.grid_size.x"),
"frozen_contract.postprocessing.grid_size.x");
382 manifest.frozen_contract.postprocessing.grid_y = RequireScalarValue<int>(
383 RequireChild(grid_size,
"y",
"frozen_contract.postprocessing.grid_size.y"),
"frozen_contract.postprocessing.grid_size.y");
384 manifest.frozen_contract.postprocessing.num_classes =
385 RequireScalarValue<int>(RequireChild(postprocessing,
"num_classes",
"frozen_contract.postprocessing.num_classes"),
386 "frozen_contract.postprocessing.num_classes");
387 manifest.frozen_contract.postprocessing.class_names =
388 RequireStringSequence(RequireChild(postprocessing,
"class_names",
"frozen_contract.postprocessing.class_names"),
389 "frozen_contract.postprocessing.class_names");
391 manifest.frozen_contract.model.stride =
392 RequirePositiveIntSequence(RequireChild(model,
"stride",
"frozen_contract.model.stride"),
"frozen_contract.model.stride");
393 manifest.frozen_contract.model.up_stride = RequirePositiveIntSequence(
394 RequireChild(model,
"up_stride",
"frozen_contract.model.up_stride"),
"frozen_contract.model.up_stride");
395 manifest.frozen_contract.model.first_up_stride = RequireScalarValue<int>(
396 RequireChild(model,
"first_up_stride",
"frozen_contract.model.first_up_stride"),
"frozen_contract.model.first_up_stride");
399 const YAML::Node pillar_map_size = RequireChild(model,
"pillar_map_size",
"frozen_contract.model.pillar_map_size");
400 EnsureSequence(pillar_map_size,
"frozen_contract.model.pillar_map_size");
401 if (pillar_map_size.size() != 2) {
402 throw std::runtime_error(
"Manifest field 'frozen_contract.model.pillar_map_size' must be a 2-element sequence");
404 manifest.frozen_contract.model.pillar_map_size = {pillar_map_size[0].as<
int>(), pillar_map_size[1].as<int>()};
408 const YAML::Node pillar_map_range = RequireChild(model,
"pillar_map_range",
"frozen_contract.model.pillar_map_range");
409 EnsureSequence(pillar_map_range,
"frozen_contract.model.pillar_map_range");
410 if (pillar_map_range.size() != 3) {
411 throw std::runtime_error(
"Manifest field 'frozen_contract.model.pillar_map_range' must contain three ranges");
413 manifest.frozen_contract.model.pillar_map_range = {
414 RequireRange2(pillar_map_range[0],
"frozen_contract.model.pillar_map_range[0]"),
415 RequireRange2(pillar_map_range[1],
"frozen_contract.model.pillar_map_range[1]"),
416 RequireRange2(pillar_map_range[2],
"frozen_contract.model.pillar_map_range[2]")};
419 manifest.runtime_defaults.preprocessing.point_feature.value_threshold =
420 LoadOptionalScalarValue<float>(LoadOptionalChild(point_feature,
"value_threshold"),
421 "runtime_defaults.preprocessing.point_feature.value_threshold", 0.0F);
422 manifest.runtime_defaults.postprocessing.class_score_threshold = RequireScalarValue<float>(
423 RequireChild(runtime_postprocessing,
"class_score_threshold",
"runtime_defaults.postprocessing.class_score_threshold"),
424 "runtime_defaults.postprocessing.class_score_threshold");
425 manifest.runtime_defaults.postprocessing.nms_score_thresholds =
426 RequireScoreThresholds(RequireChild(nms,
"score_threshold",
"runtime_defaults.postprocessing.nms.score_threshold"),
427 "runtime_defaults.postprocessing.nms.score_threshold");
428 manifest.runtime_defaults.postprocessing.nms_iou_threshold =
429 RequireScalarValue<float>(RequireChild(nms,
"iou_threshold",
"runtime_defaults.postprocessing.nms.iou_threshold"),
430 "runtime_defaults.postprocessing.nms.iou_threshold");
431 manifest.runtime_defaults.postprocessing.max_detections =
432 RequireScalarValue<int>(RequireChild(nms,
"max_num_objects",
"runtime_defaults.postprocessing.nms.max_num_objects"),
433 "runtime_defaults.postprocessing.nms.max_num_objects");
437 }
catch (
const YAML::Exception& exc) {
438 throw std::runtime_error(
"Failed to parse manifest '" + path +
"': " + std::string(exc.what()));