A console/terminal pipeline for training and running an RT-DETR (Real-Time DETR) object-detection model via ultralytics, on Windows 11 and Ubuntu Linux 24.04. The example dataset plate contains steel-plate surface defect images in 4 classes, annotated in Pascal VOC XML.

 

Note: the folder is named RF-DERT, but the bundled model and code use the ultralytics RT-DETR (rtdetr-l.pt). The name is preserved; only the Jupyter-1 suffix changed to Python-1.

 

[Folder Structure]

  • CLAUDE.md / AGENT.md: program specification (identical content).
  • CHANGELOG.md: change log.
  • copyright.txt: copyright notice.
  • data/{dataset}/: the datasets, with images, labels and annotations under train/ and val/, plus test/images, label.names and data.yaml.
  • model/{dataset}/: the starting weights (rtdetr-l.pt) and the training output (best.pt, train_metrics.json and the run artifacts).
  • tool/tools.py: shared utility helpers (delete_ipynb_checkpoints, project_root, resolve_device).
  • src/annotation/: the bundled aiohttp annotation web server (Pascal VOC XML). It is launched by src/annotation.py and runs on both Windows and Linux with the venv Python.
  • src/: the source code and the launcher scripts.
  • src/requirements.txt: the Python dependencies installed by 01_venv_create (ultralytics plus the annotation server).
  • venv/: Python virtual environment, created by 01_venv_create and removed by 99_venv_clear.

[Prerequisites]

  • Operating system: Windows 11 (the .bat launchers) or Ubuntu Linux 24.04 (the .sh launchers).
  • Python 3.10 or newer on PATH.
  • Step 1 installs ultralytics, which pulls in torch, opencv, numpy and others, so it needs network access. For an NVIDIA GPU, install a CUDA build of torch afterwards.
  • Annotation (step 3) uses the bundled src/annotation/ web server, which runs on Windows and Linux with the venv Python and needs no external binary.

[Instructions]

Step 1: Create the virtual environment

Recreate the venv and install the packages listed in src/requirements.txt.

 

Windows: src\01_venv_create.bat

Linux: bash src/01_venv_create.sh

Step 2: Activate the virtual environment (optional)

Activate the venv in the current shell. On Linux, source the script. Steps 3 to 7 activate the venv automatically, so this step is optional.

 

Windows: src\02_venv_activate.bat

Linux: source src/02_venv_activate.sh

Step 3: Annotate the images

Launch the Pascal VOC XML annotation server (port 8814 by default).

 

Windows: src\03_annotation.bat

Linux: bash src/03_annotation.sh

Step 4: Convert the dataset format

Convert the Pascal VOC XML annotations into YOLO detection labels and write data.yaml.

 

Windows: src\04_convert_yolo_format.bat --dataset plate

Linux: bash src/04_convert_yolo_format.sh --dataset plate

Step 5: Train the model

Train the RT-DETR model. The converter from step 4 runs automatically when data.yaml is missing.

 

Windows: src\05_train.bat --dataset plate --epochs 500 --device 0

Linux: bash src/05_train.sh --dataset plate --epochs 500 --device 0

Step 6: Single-image inference

Run inference on a single image. Add --show to display the result window, or --save to write it to disk.

 

Windows: src\06_inference.bat --dataset plate --source data\plate\test\images\inclusion-2.png --show

Linux: bash src/06_inference.sh --dataset plate --source data/plate/test/images/inclusion-2.png --save

Step 7: Folder inference

Run inference on a whole folder of images.

 

Windows: src\07_inference_folder.bat --dataset plate --source data\plate\test\images --save

Linux: bash src/07_inference_folder.sh --dataset plate --source data/plate/test/images --save

Step 8: Remove the virtual environment

Delete the venv/ folder.

 

Windows: src\99_venv_clear.bat

Linux: bash src/99_venv_clear.sh

[Python Entry Points]

  • src/annotation.py: launch the bundled src/annotation/ web server. Arguments: --dataset, --port (8814 by default), --split.
  • src/convert_yolo_format.py: Pascal VOC XML to YOLO detection labels plus data.yaml. Arguments: --dataset.
  • src/train.py: train the RT-DETR model. Arguments: --dataset, --batch-size, --image-size, --epochs, --workers, --lr, --device, --weights.
  • src/inference.py: single-image or folder inference. Arguments: --dataset, --source, --image-size, --device, --threshold, --weights, --show, --save.

[Dataset Format]

  • label.names: one class name per line. The plate classes are inclusion, patches, rolled_in_scale and scratches.
  • The images go in train/images/ and val/images/, with the matching Pascal VOC XML in the annotations/ folders.
  • The converter writes the YOLO detection txt files to train/labels/ and val/labels/, one line per object as class_id x_center y_center width height (normalized to 0..1), plus an ultralytics data.yaml carrying nc and names.
  • test/images/ holds unlabeled images for inference.

[References]

 

This SDK is built in AppForAI - AI Dev Tools.

 

Purchase license separately:  USD 600, permanent authorization, single APP authorization, single machine authorization, one-year activation, one-year download, one-year update, one-year email technical support.