Functions
from_datamarkin_api
- Convert Datamarkin API response to a unified Detections object.from_detectron2
- Convert Detectron2 inference results to a unified Detections object.from_ultralytics
- Convert Ultralytics YOLO results to a unified Detections object.from_transformers
- Convert Transformers library results to a unified Detections object.from_sam
- Convert Segment Anything Model (SAM) results to a unified Detections object.from_datamarkin_csv
- Convert CSV data from Datamarkin format to a unified Detections object.
from_datamarkin_api
Convert Datamarkin API response to a unified Detections object. Processes detection results from Datamarkin’s cloud-based object detection API, extracting bounding boxes, segmentation masks, keypoints, class labels, and confidence scores into PixelFlow’s standardized format for further processing.Function Signature
Parameters
Datamarkin API response dictionary containing nested ‘predictions’ -> ‘objects’ structure with detection data. Each object should have ‘bbox’, ‘mask’, ‘keypoints’, ‘class’, and ‘bbox_score’ fields.
Returns
Unified Detections object containing all detected objects with standardized XYXY bounding boxes, polygon masks, keypoint data, and confidence scores. Empty Detections object if no predictions.
Example
Example
from_detectron2
Convert Detectron2 inference results to a unified Detections object. Extracts bounding boxes, confidence scores, class IDs, segmentation masks, and keypoints from Detectron2’s instances format and standardizes them into PixelFlow’s Detection objects. Handles automatic tensor-to-numpy conversion and CPU transfer for efficient processing.Function Signature
Parameters
Detectron2 inference results dictionary containing ‘instances’ key with prediction data including pred_boxes, scores, pred_classes, pred_masks, and pred_keypoints. Results should be from DefaultPredictor output.
Returns
Unified Detections object with all detected instances converted to standardized format. Contains XYXY bounding boxes as lists, boolean numpy array masks, integer class IDs, and float confidences. Returns empty Detections if no instances found.
Example
Example
from_ultralytics
Convert Ultralytics YOLO results to a unified Detections object. Supports both detection and segmentation models, handling bounding boxes, confidence scores, class IDs, segmentation masks, and tracker IDs. Automatically processes letterbox padding removal and mask resizing to original image dimensions with precise coordinate transformation.Function Signature
Parameters
YOLO results from Ultralytics library prediction or tracking. Can be single Result object or list containing one Result object. Must have boxes attribute with detection data.
Returns
Unified Detections object containing all detected objects with standardized XYXY bounding boxes, boolean binary masks resized to original image dimensions, polygon segments as integer coordinates, and tracker IDs if available. Empty Detections if no boxes found.
Example
Example
from_transformers
Convert Transformers library results to a unified Detections object. Placeholder function for future integration with Hugging Face Transformers object detection and segmentation models. Will support DETR, RT-DETR, and other transformer-based detection architectures.Function Signature
Parameters
Results from Transformers library object detection models. Expected format includes boxes, labels, and scores tensors.
Returns
Empty Detections object. Full implementation pending.
Example
Example
from_sam
Convert Segment Anything Model (SAM) results to a unified Detections object. Placeholder function for integration with Meta’s Segment Anything Model (SAM) for interactive and automatic segmentation tasks. Will support prompt-based segmentation with point, box, and text prompts.Function Signature
Parameters
Results from SAM model inference including masks, iou_predictions, and low_res_logits from SamPredictor or SamAutomaticMaskGenerator output.
Returns
Empty Detections object. Full implementation pending.
Example
Example
from_datamarkin_csv
Convert CSV data from Datamarkin format to a unified Detections object. Processes normalized coordinates from CSV annotation format and converts them to pixel coordinates using the provided image dimensions. Handles both bounding box rectangles and segmentation polygon data with automatic coordinate denormalization and validation.Function Signature
Parameters
Pandas DataFrame or DataFrame group containing CSV rows with required columns ‘xmin’, ‘ymin’, ‘xmax’, ‘ymax’, ‘segmentation’, ‘class’, and optional ‘confidence’. All coordinate values must be normalized floats in range [0.0, 1.0].
Image height in pixels for coordinate denormalization. Must be positive integer representing actual image height.
Image width in pixels for coordinate denormalization. Must be positive integer representing actual image width.
Returns
Unified Detections object with pixel coordinates converted from normalized values. Contains XYXY bounding boxes as integers, polygon masks as lists of (x, y) tuples, and preserved class labels. Empty Detections if group contains no rows.
Example
Example