datamint.importers
Format-specific importers that parse an externally-labeled dataset and upload it to a Datamint project. See Client Python API for a narrative walkthrough and the 05_import_dataset.ipynb tutorial notebook.
COCO
- class datamint.importers.coco.COCOBox(label, x, y, width, height)
Bases:
object- Parameters:
label (
str)x (
float)y (
float)width (
float)height (
float)
- height: float
- label: str
- width: float
- x: float
- y: float
- class datamint.importers.coco.COCOImportResult(project, resource_ids, n_images_uploaded, n_boxes_uploaded, errors=<factory>)
Bases:
object- Parameters:
project (
Project|str)resource_ids (
list[str])n_images_uploaded (
int)n_boxes_uploaded (
int)errors (
list[tuple[str,Exception]])
- errors: list[tuple[str, Exception]]
- n_boxes_uploaded: int
- n_images_uploaded: int
- resource_ids: list[str]
- class datamint.importers.coco.COCOImporter(annotations_file, images_dir=None)
Bases:
objectParse a COCO-format annotations file and upload it to a Datamint project.
- Parameters:
annotations_file (
str|Path)images_dir (
str|Path|None)
- import_to_project(project, api=None, *, tags=None, imported_from='coco-import', on_error='raise', progress_bar=True)
Upload the parsed images and box annotations to a Datamint project.
Calls
parse()first (reusing the cached result if already called).apidefaults to a newApiinstance if not given.- Parameters:
- Return type:
- parse(force=False)
Read and validate the COCO JSON file.
Cached after the first call; pass
force=Trueto reparse.- Raises:
ValueError – If the file is structurally invalid (missing required keys, or an annotation references an unknown category/image id).
- Parameters:
force (
bool)- Return type:
- class datamint.importers.coco.COCOParseResult(samples, class_names, missing_images, unsupported_annotations)
Bases:
object- Parameters:
samples (
list[COCOSample])class_names (
list[str])missing_images (
list[str])unsupported_annotations (
int)
- class_names: list[str]
- missing_images: list[str]
- property num_boxes: int
- property num_images: int
- samples: list[COCOSample]
- unsupported_annotations: int
Pascal VOC
- class datamint.importers.pascal_voc.PascalVOCBox(label, x1, y1, x2, y2, difficult=False)
Bases:
object- Parameters:
label (
str)x1 (
float)y1 (
float)x2 (
float)y2 (
float)difficult (
bool)
- difficult: bool = False
- label: str
- x1: float
- x2: float
- y1: float
- y2: float
- class datamint.importers.pascal_voc.PascalVOCImportResult(project, resource_ids, n_images_uploaded, n_boxes_uploaded, errors=<factory>)
Bases:
object- Parameters:
project (
Project|str)resource_ids (
list[str])n_images_uploaded (
int)n_boxes_uploaded (
int)errors (
list[tuple[str,Exception]])
- errors: list[tuple[str, Exception]]
- n_boxes_uploaded: int
- n_images_uploaded: int
- resource_ids: list[str]
- class datamint.importers.pascal_voc.PascalVOCImporter(annotations_dir, images_dir)
Bases:
objectParse a Pascal VOC-format annotations directory and upload it to a Datamint project.
Only bounding-box annotations (the
bndboxfield) are imported.- Parameters:
annotations_dir (
str|Path)images_dir (
str|Path)
- import_to_project(project, api=None, *, tags=None, imported_from='pascal-voc-import', on_error='raise', progress_bar=True)
Upload the parsed images and box annotations to a Datamint project.
Calls
parse()first (reusing the cached result if already called).apidefaults to a newApiinstance if not given.- Parameters:
- Return type:
- parse(force=False)
Read and validate the Pascal VOC XML annotation files.
Cached after the first call; pass
force=Trueto reparse.- Raises:
ValueError – If
annotations_dirdoesn’t exist, or an XML file is missing its requiredfilenameelement.- Parameters:
force (
bool)- Return type:
- class datamint.importers.pascal_voc.PascalVOCParseResult(samples, class_names, missing_images, unsupported_annotations)
Bases:
object- Parameters:
samples (
list[PascalVOCSample])class_names (
list[str])missing_images (
list[str])unsupported_annotations (
int)
- class_names: list[str]
- missing_images: list[str]
- property num_boxes: int
- property num_images: int
- samples: list[PascalVOCSample]
- unsupported_annotations: int
- class datamint.importers.pascal_voc.PascalVOCSample(image_path, file_name, boxes=<factory>)
Bases:
object- Parameters:
image_path (
Path)file_name (
str)boxes (
list[PascalVOCBox])
- boxes: list[PascalVOCBox]
- file_name: str
- image_path: Path
YOLO
- class datamint.importers.yolo.YOLOBox(label, x1, y1, x2, y2)
Bases:
object- Parameters:
label (
str)x1 (
float)y1 (
float)x2 (
float)y2 (
float)
- label: str
- x1: float
- x2: float
- y1: float
- y2: float
- class datamint.importers.yolo.YOLOImportResult(project, resource_ids, n_images_uploaded, n_boxes_uploaded, errors=<factory>)
Bases:
object- Parameters:
project (
Project|str)resource_ids (
list[str])n_images_uploaded (
int)n_boxes_uploaded (
int)errors (
list[tuple[str,Exception]])
- errors: list[tuple[str, Exception]]
- n_boxes_uploaded: int
- n_images_uploaded: int
- resource_ids: list[str]
- class datamint.importers.yolo.YOLOImporter(images_dir, labels_dir, *, class_names=None, data_yaml=None, image_extensions=('.jpg', '.jpeg', '.png', '.bmp', '.tif', '.tiff', '.webp'))
Bases:
objectParse a YOLO-format (images + normalized-bbox label .txt files) dataset and upload it to a Datamint project.
- Parameters:
images_dir (
str|Path)labels_dir (
str|Path)class_names (
Sequence[str] |None)data_yaml (
str|Path|None)image_extensions (
Sequence[str])
- import_to_project(project, api=None, *, tags=None, imported_from='yolo-import', on_error='raise', progress_bar=True)
Upload the parsed images and box annotations to a Datamint project.
Calls
parse()first (reusing the cached result if already called).apidefaults to a newApiinstance if not given.- Parameters:
- Return type:
- parse(force=False)
Read and validate the YOLO label files.
Cached after the first call; pass
force=Trueto reparse.- Raises:
ValueError – If class names can’t be resolved, a label line references an unknown class index, or a normalized coordinate is outside the expected
[0, 1]range.- Parameters:
force (
bool)- Return type:
- class datamint.importers.yolo.YOLOParseResult(samples, class_names, missing_images, unsupported_annotations)
Bases:
object- Parameters:
samples (
list[YOLOSample])class_names (
list[str])missing_images (
list[str])unsupported_annotations (
int)
- class_names: list[str]
- missing_images: list[str]
- property num_boxes: int
- property num_images: int
- samples: list[YOLOSample]
- unsupported_annotations: int