コンテンツにスキップ

ObjectDetection3DTracer Class

キーワード mmdet3d_mode(v0.5.0 で非推奨)

v0.4.x では、mmdet3d を使っているモデルで mmdet3d_mode=True を指定します (ModelSpec を指定している場合は省略できます)。v0.5.0 以降は指定不要です — 指定しても動作しますが、非推奨の警告が出ます。このキーワードはプリセット解決時に 消費されるため、以下の __init__ のシグネチャには現れません。 ObjectDetection3DLogger / ObjectDetection3DDataFilter でも同様です。

ml_debugger.training.object_detection_3d.object_detection_3d_torchtracer.ObjectDetection3DTrainingTorchTracer

Bases: BaseTrainingTracer, ObjectDetection3DTorchTracer

Base BaseTrainingTracer for 3D object detection tasks using PyTorch models.

Subclasses must implement the following abstract methods
  • detect(model): Static method to check if this subclass handles the model.
  • _get_n_class(model): Extract number of classes from the model.
  • _register_model_hooks(model): Register forward hooks for logit capture.
  • _parse_model_output(model_output): Convert model output to a standardized Detection3DOutput.
Optionally override
  • _apply_nms_config(model, nms_config): Apply NMS parameters to the model.

__init__(model, model_name, version_name, target_layers=None, additional_fields=None, additional_label_fields=None, auto_sync=False, force_table_recreate=False, api_endpoint=None, api_key=None, n_class=None, score_thresh=None, iou_thresh=None, max_detections_per_image=None, pc_range=None, ground_truth_provider=None, max_detections_per_frame=None)

Initialize 3D object detection training tracer.

引数:

名前 タイプ デスクリプション デフォルト

model

Module

PyTorch model to trace.

必須

model_name

str

Name of the ML model.

必須

version_name

str

Version identifier for the ML model.

必須

target_layers

Optional[Dict[str, str]]

Mapping of layer aliases to module paths.

None

additional_fields

Optional[List[dict]]

Extra fields for database schema.

None

additional_label_fields

Optional[List[dict]]

Extra fields for groundtruth database schema.

None

auto_sync

bool

Enable background syncing of logged data.

False

force_table_recreate

bool

Whether to drop and recreate existing tables.

False

api_endpoint

Optional[str]

URL of the service API for data upload.

None

api_key

Optional[str]

API key for authenticating with the service.

None

n_class

Optional[int]

Number of classes. Auto-detected from model if None.

None

score_thresh

Optional[float]

Minimum score threshold for detections. None to infer from the model's test_cfg.

None

iou_thresh

Optional[float]

BEV IoU threshold for NMS. None to infer from the model's test_cfg.

None

max_detections_per_image

Optional[int]

Maximum detections per frame after NMS. None to infer from the model's test_cfg.

None

max_detections_per_frame

Optional[int]

The name earlier releases and existing scripts use for max_detections_per_image, still accepted; passing both with different values raises ValueError.

None

pc_range

Optional[List[float]]

Deprecated. Point cloud range [x_min, y_min, z_min, x_max, y_max, z_max] recorded beside the ground truth. Declare it in the ModelSpec instead (Coords3D(..., pc_range=[...])); without one, the range the model holds is recorded.

None

ground_truth_provider

Optional[Any]

Optional provider implementing resolve(sample_tokens: List[str]) -> List[Dict[str, Any]]. Used when ground_truth is omitted at call time.

None

__call__(model_input, ground_truth, input_ids, dataset_type='train', n_epoch=None, **kwargs)

Invoke the tracer on a single inference, recording I/O data.

引数:

名前 タイプ デスクリプション デフォルト

model_input

Any

Input data for the model. Can be a torch.Tensor (point cloud) or a dict (MMDetection3D format with points, img, img_metas).

必須

ground_truth

Optional[Any]

Ground truth 3D bounding boxes and labels. If omitted, ground_truth_provider must be configured. Accepts List[Dict] or Dict[str, List] format with keys: 'boxes_3d' (N,7), 'labels_3d' (N,), optional 'velocities' (N,2), or MMDet3D-style dict with gt_bboxes_3d / gt_labels_3d.

必須

input_ids

List[str]

Identifiers of each input data.

必須

dataset_type

str

Identifier of input dataset.

'train'

n_epoch

Optional[int]

Number identifier of training iteration.

None

**kwargs

Any

Additional keyword arguments passed to _parse_and_save_io_data.

{}

戻り値:

タイプ デスクリプション
Any

The raw output produced by the model.

get_hooked_features(layer_name)

Retrieve the captured output for a given layer alias.

引数:

名前 タイプ デスクリプション デフォルト

layer_name

str

Alias of the layer whose activation was captured.

必須

戻り値:

名前 タイプ デスクリプション
Any Any

Activation data stored for the specified layer.

発生:

タイプ デスクリプション
KeyError

If no activation has been captured for layer_name.

export(output_path=None, n_epoch=None)

Export extracted features and ground truth data into a ZIP archive.

引数:

名前 タイプ デスクリプション デフォルト

output_path

Optional[str]

Path or directory for saving the ZIP file. If no .zip extension, the default filename is appended. Defaults to cwd.

None

n_epoch

Optional[int]

Target epoch number. If None, exports all epochs.

None

戻り値:

タイプ デスクリプション
Optional[Path]

Path to the created ZIP file, or None on non-primary distributed ranks. A

Optional[Path]

model with named outputs returns one path per output name instead.

wait_for_save(n_epoch=None, interval=3, *, force=False, mode='merge')

Flush pending writes and upload extracted features and ground truth.

引数:

名前 タイプ デスクリプション デフォルト

n_epoch

Optional[int]

Target epoch to upload. If None, uploads the un-epoched tables (extracted_feature / groundtruth).

None

interval

int

Retained for backward compatibility; unused now that the background-sync path is disabled.

3

force

bool

Upload even when nothing has been marked unsaved since the last upload.

False

mode

str

How the server merges this upload into previously uploaded data for the same (version, data_type). One of:

  • "merge" (default): upsert by key (extracted_feature: output_hash / groundtruth: label_hash); keeps every other existing row regardless of dataset_type.
  • "replace": replaces the rows of the dataset_types present in this upload; keeps rows of dataset_types not in the upload.
  • "replace_all": drops all previously uploaded data for the (version, data_type) then saves this upload.

The mode is honored by API server >= 0.4.2; older servers ignore it and behave as "replace_all". If the column set changed since a previous upload (e.g. additional fields differ), "merge" / "replace" are rejected by the server -- use "replace_all". To purge rows that no longer exist locally, use "replace" or "replace_all".

'merge'

発生:

タイプ デスクリプション
ValueError

If mode is not one of merge / replace / replace_all.

upload(n_epoch=None, *, force=False, mode='merge')

Flush pending writes and upload extracted features and ground truth.

引数:

名前 タイプ デスクリプション デフォルト

n_epoch

Optional[int]

Target epoch to upload. If None, uploads the un-epoched tables (extracted_feature / groundtruth).

None

force

bool

Upload even when nothing has been marked unsaved since the last upload.

False

mode

str

How the server merges this upload into previously uploaded data for the same (version, data_type). One of:

  • "merge" (default): upsert by key (extracted_feature: output_hash / groundtruth: label_hash); keeps every other existing row regardless of dataset_type.
  • "replace": replaces the rows of the dataset_types present in this upload; keeps rows of dataset_types not in the upload.
  • "replace_all": drops all previously uploaded data for the (version, data_type) then saves this upload.

The mode is honored by API server >= 0.4.2; older servers ignore it and behave as "replace_all". If the column set changed since a previous upload (e.g. additional fields differ), "merge" / "replace" are rejected by the server -- use "replace_all". To purge rows that no longer exist locally, use "replace" or "replace_all".

'merge'

発生:

タイプ デスクリプション
ValueError

If mode is not one of merge / replace / replace_all.

get_statistics()

Count what this instance has recorded locally, without returning any of it.

This is the supported way to confirm what was recorded: how many rows, how many distinct inputs and how many ground-truth rows each recorded group holds. It returns counts only, never recorded values. Writes still pending are completed first, so the counts include everything recorded so far. In a distributed run, each process counts the records it wrote itself.

戻り値:

タイプ デスクリプション
Any

A list with one entry per (dataset_type, n_epoch) group present in the

Any

local records, each of the form ``{"dataset_type": str, "n_epoch":

Any

Optional[int], "rows": int, "inputs": int, "ground_truth_rows": int}`` --

Any

n_epoch is None for records made without an epoch, inputs counts

Any

distinct input ids, and ground_truth_rows is 0 when no ground truth is

Any

recorded. A model with named outputs returns {output name: list}.

drop_epoch_data(n_epoch)

Delete the locally recorded rows of one epoch.

引数:

名前 タイプ デスクリプション デフォルト

n_epoch

Optional[int]

The epoch whose rows are deleted. None deletes ONLY the rows recorded without an epoch; it does NOT delete every epoch, and rows recorded with an epoch are left untouched. There is no default, so a call always names what it deletes.

必須

戻り値:

タイプ デスクリプション
Dict[str, int]

Dict[str, int]: Number of deleted rows in the form {'extracted_feature': N, 'ground_truth': M}. The ground_truth key is absent when there is no ground truth (logging_mode). A model with named outputs returns one such dict per output name instead.

発生:

タイプ デスクリプション
TypeError

If n_epoch is neither an int nor None.

drop_version_data()

Drop all tables for the current (model, version) and recreate them empty.

Provides the same behavior as the existing force_table_recreate=True path as an explicit method. Internally it re-invokes __initialize_session(force_table_recreate=True) and starts a fresh repository / async batch writer.

Note

Before re-init, fully stop async_batch_writer with flush() + stop(), then re-initialize the session. Skipping this leaves a daemon thread holding onto the old session.