Ikomia HUB
train_rf_detr_seg

train_rf_detr_seg

About

Apache-2.0

Train RF-DETR instance segmentation models

Task: Instance segmentation
DETR
instance
segmentation
roboflow
training

Train RF-DETR instance segmentation models.

Desk object segmentation

🚀 Use with Ikomia API

1. Install Ikomia API

We strongly recommend using a virtual environment. If you're not sure where to start, we offer a tutorial here.

pip install ikomia

2. Create your workflow

from ikomia.dataprocess.workflow import Workflow

# Init your workflow
wf = Workflow()

# Add COCO instance segmentation dataset loader
coco = wf.add_task(name="dataset_coco")

coco.set_parameters({
"json_file": "path/to/instances_train.json",
"image_folder": "path/to/images",
"task": "instance_segmentation",
})

# Add training algorithm
train = wf.add_task(name="train_rf_detr_seg", auto_connect=True)

# Launch training
wf.run()

☀️ Use with Ikomia Studio

Ikomia Studio offers a friendly UI with the same features as the API.

  • If you haven't started using Ikomia Studio yet, download and install it from this page.
  • For additional guidance on getting started with Ikomia Studio, check out this blog post.

📝 Set algorithm parameters

  • model_name (str) - default rf-detr-seg-medium: Name of the RF-DETR segmentation model. Available models:
    • rf-detr-seg-nano
    • rf-detr-seg-small
    • rf-detr-seg-medium
    • rf-detr-seg-base
    • rf-detr-seg-large
  • model_weight_file (str, optional): Path to custom starting weights.
  • dataset_folder (str): Folder where the Ikomia dataset is converted to COCO format.
  • batch_size (int) - default 2: Number of samples processed before the model is updated.
  • grad_accum_steps (int) - default 4: Number of gradient accumulation steps.
  • epochs (int) - default 100: Number of complete passes through the training dataset.
  • dataset_split_ratio (float) - default 0.9: Ratio used to split the dataset into train and validation sets.
  • input_size (int) - default 576: Training image size. It is adjusted to the selected RF-DETR segmentation model block size when needed.
  • workers (int) - default 0: Number of worker threads for data loading. Use 0 on Windows if multiprocessing is unstable.
  • weight_decay (float) - default 1e-4: Weight decay regularization.
  • lr (float) - default 1e-4: Learning rate.
  • lr_encoder (float) - default 1.5e-4: Encoder learning rate.
  • output_folder (str): Folder where training runs, weights, and class_names.yaml are saved.
  • early_stopping (bool) - default False: Stored for compatibility with the UI and future RF-DETR training options.
  • early_stopping_patience (int) - default 10: Stored with the training configuration when early stopping is enabled.

The training dataset must contain polygon instance masks. For Ikomia datasets, those masks are read from segmentation_poly and exported to COCO segmentation annotations.

Pretrained RF-DETR segmentation weights are cached in train_rf_detr_seg/weights, following the same local cache pattern as infer_rf_detr.

Parameters should be in strings format when added to the dictionary.

from ikomia.dataprocess.workflow import Workflow

# Init your workflow
wf = Workflow()

# Add COCO instance segmentation dataset loader
coco = wf.add_task(name="dataset_coco")

coco.set_parameters({
"json_file": "path/to/instances_train.json",
"image_folder": "path/to/images",
"task": "instance_segmentation",
})

# Add training algorithm
train = wf.add_task(name="train_rf_detr_seg", auto_connect=True)

train.set_parameters({
"model_name": "rf-detr-seg-medium",
"epochs": "100",
"batch_size": "2",
"grad_accum_steps": "4",
"input_size": "576",
"dataset_split_ratio": "0.9",
"workers": "0",
"weight_decay": "1e-4",
"lr": "1e-4",
"lr_encoder": "1.5e-4",
"output_folder": "path/to/output/folder",
})

# Launch training
wf.run()

After training, use the generated weights and class_names.yaml with infer_rf_detr_seg.

Developer

  • Ikomia
    Ikomia

License

Apache License 2.0
Read license full text

A permissive license whose main conditions require preservation of copyright and license notices. Contributors provide an express grant of patent rights. Licensed works, modifications, and larger works may be distributed under different terms and without source code.

PermissionsConditionsLimitations

Commercial use

License and copyright notice

Trademark use

Modification

State changes

Liability

Distribution

Warranty

Patent use

Private use

This is not legal advice: this description is for informational purposes only and does not constitute the license itself. Provided by choosealicense.com.