Docs /Templates/ sinapsis-rfdetr

RFDETRTrain

sinapsis-rfdetrRFDetrimagemodelsrfdetrobject_detection

Python template · sinapsis_rfdetr.templates.rfdetr_train

Overview

A class that handles the training process for the RF-DETR model.

Capabilities

Capabilities: not set

Installation

Install the published package using pip or uv.

Terminalbash
pip install sinapsis-rfdetr==1.0.0
uv pip install sinapsis-rfdetr==1.0.0
uv add sinapsis-rfdetr==1.0.0

Configuration

Effective fields from the inspector schema, including nested Pydantic model fields.

callback

Specifies the callback function to be executed at specific stages during the training process. Default is "on_fit_epoch_end".

typing.Literal['on_fit_epoch_end', 'on_train_batch_start', 'on_train_end']
Optional
Default: "on_fit_epoch_end"
metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
model_params
RFDETRBaseConfig
Optional
Default: null
amp
bool
Optional
Default: true
device
typing.Literal['cpu', 'cuda', 'mps']
Optional
Default: "cuda"
encoder
typing.Literal['dinov2_windowed_small', 'dinov2_windowed_base']
Optional
Default: "dinov2_windowed_small"
ca_nheads
int
Optional
Default: 16
sa_nheads
int
Optional
Default: 8
two_stage
bool
Optional
Default: true
dec_layers
int
Optional
Default: 3
group_detr
int
Optional
Default: 13
hidden_dim
int
Optional
Default: 256
layer_norm
bool
Optional
Default: true
num_select
int
Optional
Default: 300
patch_size
int
Optional
Default: 14
resolution
int
Optional
Default: 560
num_classes
int
Optional
Default: 90
num_queries
int
Optional
Default: 300
num_windows
int
Optional
Default: 4
bbox_reparam
bool
Optional
Default: true
dec_n_points
int
Optional
Default: 2
projector_scale
typing.List[typing.Literal['P3', 'P4', 'P5']]
Optional
Default: ["P4"]
pretrain_weights
typing.Optional[str]
Optional
Default: "rf-detr-base.pth"
out_feature_indexes
typing.List[int]
Optional
Default: [2,5,8,11]
lite_refpoint_refine
bool
Optional
Default: true
gradient_checkpointing
bool
Optional
Default: false
positional_encoding_size
int
Optional
Default: 37
training_params
An instance of `TrainConfig` containing the training parameters for training the RF-DETR model. If not specified, default parameters will be used. Key parameters that can be included in `training_params` are: -… Read full field description

An instance of `TrainConfig` containing the training parameters for training the RF-DETR model. If not specified, default parameters will be used. Key parameters that can be included in `training_params` are: - `dataset_dir`: Path to the COCO-formatted dataset directory, containing `train`, `valid`, and `test` folders, each containing an `_annotations.coco.json` file. - `epochs`: Total number of training epochs. - `batch_size`: Number of samples per training iteration. Adjust based on available GPU memory and use in conjunction with `grad_accum_steps` to maintain the intended effective batch size. - `grad_accum_steps`: Number of mini-batches over which gradients are accumulated. This effectively increases the total batch size without requiring as much memory at once, making it useful for smaller GPUs - `lr`: Learning rate for optimization. - `resume`: Path to a saved checkpoint for resuming training. Note on memory usage: Adjust `batch_size` and `grad_accum_steps` based on GPU VRAM. For example: - On powerful GPUs like the A100, you can use `batch_size=16` and `grad_accum_steps=1`. - On smaller GPUs like the T4, you may want to use `batch_size=4` and `grad_accum_steps=4`. Complete documentation for the available training parameters and an example dataset structure can be found on the RF-DETR GitHub: https://github.com/roboflow/rf-detr/tree/main

TrainConfig
Optional
Default: null
lr
float
Optional
Default: 0.0001
run
typing.Optional[str]
Optional
Default: null
wandb
bool
Optional
Default: false
epochs
int
Optional
Default: 100
ema_tau
int
Optional
Default: 100
lr_drop
int
Optional
Default: 100
project
typing.Optional[str]
Optional
Default: null
use_ema
bool
Optional
Default: true
run_test
bool
Optional
Default: true
drop_path
float
Optional
Default: 0
ema_decay
float
Optional
Default: 0.993
batch_size
int
Optional
Default: 4
group_detr
int
Optional
Default: 13
lr_encoder
float
Optional
Default: 0.00015
num_select
int
Optional
Default: 300
output_dir
str
Optional
Default: "output"
class_names
typing.List[str]
Optional
Default: null
dataset_dirRequired
str
Required
Default: null
ia_bce_loss
bool
Optional
Default: true
multi_scale
bool
Optional
Default: true
num_workers
int
Optional
Default: 2
tensorboard
bool
Optional
Default: true
dataset_file
typing.Literal['coco', 'o365', 'roboflow']
Optional
Default: "roboflow"
weight_decay
float
Optional
Default: 0.0001
cls_loss_coef
float
Optional
Default: 1
warmup_epochs
int
Optional
Default: 0
early_stopping
bool
Optional
Default: false
expanded_scales
bool
Optional
Default: true
grad_accum_steps
int
Optional
Default: 4
lr_component_decay
float
Optional
Default: 0.7
lr_vit_layer_decay
float
Optional
Default: 0.8
checkpoint_interval
int
Optional
Default: 10
square_resize_div_64
bool
Optional
Default: true
early_stopping_use_ema
bool
Optional
Default: false
early_stopping_patience
int
Optional
Default: 10
early_stopping_min_delta
float
Optional
Default: 0.001
do_random_resize_via_padding
bool
Optional
Default: false

Configuration example

Example from the Python docstring:

yaml
agent:
      name: my_test_agent
    templates:
    - template_name: InputTemplate
      class_name: InputTemplate
      attributes: {}
    - template_name: RFDETRTrain
      class_name: RFDETRTrain
      template_input: InputTemplate
      attributes:
        training_params:
            dataset_dir: '/path/to/dataset'
            epochs: 10
            batch_size: 4
            grad_accum_steps: 4
            lr: 1e-4
            early_stopping: True
            resume: 'path/to/checkpoint'
Show schema-based configuration skeleton
yaml
templates:
  - template_name: "RFDETRTrain"
    class_name: "RFDETRTrain"
    attributes:
      callback: "on_fit_epoch_end"
      model_params:
        amp: true
        device: "cuda"
        encoder: "dinov2_windowed_small"
        ca_nheads: 16
        sa_nheads: 8
        two_stage: true
        dec_layers: 3
        group_detr: 13
        hidden_dim: 256
        layer_norm: true
        num_select: 300
        patch_size: 14
        resolution: 560
        num_classes: 90
        num_queries: 300
        num_windows: 4
        bbox_reparam: true
        dec_n_points: 2
        projector_scale: ["P4"]
        pretrain_weights: "rf-detr-base.pth"
        out_feature_indexes: [2, 5, 8, 11]
        lite_refpoint_refine: true
        gradient_checkpointing: false
        positional_encoding_size: 37
      training_params:
        lr: 0.0001
        run: null
        wandb: false
        epochs: 100
        ema_tau: 100
        lr_drop: 100
        project: null
        use_ema: true
        run_test: true
        drop_path: 0
        ema_decay: 0.993
        batch_size: 4
        group_detr: 13
        lr_encoder: 0.00015
        num_select: 300
        output_dir: "output"
        class_names: null
        dataset_dir: "<required>"
        ia_bce_loss: true
        multi_scale: true
        num_workers: 2
        tensorboard: true
        dataset_file: "roboflow"
        weight_decay: 0.0001
        cls_loss_coef: 1
        warmup_epochs: 0
        early_stopping: false
        expanded_scales: true
        grad_accum_steps: 4
        lr_component_decay: 0.7
        lr_vit_layer_decay: 0.8
        checkpoint_interval: 10
        square_resize_div_64: true
        early_stopping_use_ema: false
        early_stopping_patience: 10
        early_stopping_min_delta: 0.001
        do_random_resize_via_padding: false

Inheritance

Immediate parent: sinapsis_rfdetr.templates.rfdetr_model_base.RFDETRModelBase

Environment variables

Environment definitions belong to their canonical Python modules.

No directly related environment variables listed.