Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:NVIDIA DALI EfficientDet Net

From Leeroopedia
Revision as of 15:53, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/NVIDIA_DALI_EfficientDet_Net.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Object_Detection, TensorFlow
Last Updated 2026-02-08 16:00 GMT

Overview

Implements the complete EfficientDet object detection network as a Keras Model with integrated training step, validation step, and mAP computation.

Description

This module provides the `EfficientDetNet` class, a `tf.keras.Model` subclass that assembles the full EfficientDet architecture for object detection. It combines an EfficientNet backbone for feature extraction with a Bi-directional Feature Pyramid Network (BiFPN) for multi-scale feature fusion and separate classification (ClassNet) and box regression (BoxNet) prediction heads.

The model initialization configures the backbone network (using `efficientnet_builder`), constructs resampling layers for coarser feature levels, builds FPN cells for feature fusion, and sets up ClassNet and BoxNet heads with configurable parameters including number of anchors (derived from aspect ratios and scales), number of FPN filters, activation types, and separable convolution options. The class also provides built-in training metrics (mean loss, learning rate) and mAP tracking.

The training workflow is managed through `train_step()` which unpacks inputs into features and multi-level classification/box targets, computes forward pass through backbone and detection heads, calculates focal loss for classification and huber/IoU loss for box regression with L2 regularization, and applies gradient updates. A `test_step()` method performs inference and computes mAP using IoU-based matching. The model supports variable freezing via regex patterns and gradient checkpointing for memory efficiency.

Usage

Use this class as the primary model for EfficientDet-based object detection training. Instantiate with a model name (e.g., 'efficientdet-d1') or a custom params dictionary, then use standard Keras fit/evaluate workflows or custom training loops.

Code Reference

Source Location

Signature

class EfficientDetNet(tf.keras.Model):
    def __init__(self, model_name=None, params=None, name=""): ...

    def train_step(self, data): ...
    def test_step(self, data): ...
    def call(self, inputs, training): ...

    # Internal methods
    def _freeze_vars(self) -> list: ...
    def _reg_l2_loss(self, weight_decay, regex=r".*(kernel|weight):0$") -> tf.Tensor: ...
    def _unpack_inputs(self, inputs) -> Tuple[tf.Tensor, dict]: ...
    def _unpack_outputs(self, cls_out_list, box_out_list) -> Tuple[dict, dict]: ...
    def _calc_mAP(self, pred_boxes, pred_scores, pred_classes, gt_boxes, gt_classes): ...

Import

from model.efficientdet_net import EfficientDetNet

model = EfficientDetNet(model_name="efficientdet-d1")

I/O Contract

Inputs

Name Type Required Description
model_name str No EfficientDet model variant (e.g., 'efficientdet-d0' through 'efficientdet-d7x')
params dict No Custom parameter dictionary (alternative to model_name)
inputs tuple Yes Training input tuple: (features, num_positives, boxes, classes, *cls_targets, *box_targets)

Outputs

Name Type Description
cls_outputs dict Per-level classification predictions keyed by level number
box_outputs dict Per-level box regression predictions keyed by level number
train metrics dict Dictionary with 'mean_loss', 'loss', 'lr' during training
eval metrics dict Dictionary with 'mAP' during evaluation

Usage Examples

Train EfficientDet-D1

import hparams_config
from model.efficientdet_net import EfficientDetNet

# Create model
config = hparams_config.get_efficientdet_config("efficientdet-d1")
config.override({"batch_size": 8, "num_classes": 91})
model = EfficientDetNet(params=config.as_dict())

# Compile and train
model.compile(optimizer=tf.keras.optimizers.SGD(learning_rate=0.08, momentum=0.9))
model.fit(train_dataset, epochs=300, validation_data=val_dataset)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment