Implementation:Datajuicer Data juicer ImageDetectionYoloMapper
| Knowledge Sources | |
|---|---|
| Domains | Data_Processing, Mapping |
| Last Updated | 2026-02-14 16:00 GMT |
Overview
Concrete tool for performing object detection on images using YOLO provided by Data-Juicer.
Description
ImageDetectionYoloMapper is a mapper operator that uses a YOLO model to detect objects in images, returning bounding boxes and class labels. It loads a YOLO model (default: yolo11n.pt) via the ultralytics library and runs inference on each image with configurable image size, confidence threshold, and IoU threshold. Bounding boxes in xywh format and class labels are stored in the sample's metadata under bbox_tag and class_label_tag respectively. Requires CUDA acceleration.
Usage
Use when you need object detection annotations for images, providing spatial object information for downstream operators such as character detection and image analysis pipelines.
Code Reference
Source Location
- Repository: Datajuicer_Data_juicer
- File: data_juicer/ops/mapper/image_detection_yolo_mapper.py
Signature
@OPERATORS.register_module("image_detection_yolo_mapper")
class ImageDetectionYoloMapper(Mapper):
def __init__(self,
imgsz=640,
conf=0.05,
iou=0.5,
model_path="yolo11n.pt",
*args, **kwargs):
Import
from data_juicer.ops.mapper.image_detection_yolo_mapper import ImageDetectionYoloMapper
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| imgsz | int | No | Resolution for image resizing, defaults to 640 |
| conf | float | No | Confidence score threshold, defaults to 0.05 |
| iou | float | No | IoU (Intersection over Union) score threshold, defaults to 0.5 |
| model_path | str | No | Path to the YOLO model, defaults to "yolo11n.pt" |
Outputs
| Name | Type | Description |
|---|---|---|
| samples | Dict | Transformed samples with bbox_tag and class_label_tag in meta field |
Usage Examples
process:
- image_detection_yolo_mapper:
imgsz: 640
conf: 0.05
iou: 0.5
model_path: "yolo11n.pt"