18 from typing
import Any, Final, List, Set
20 from abc
import ABC, abstractmethod
24 from ..annotation
import CoretexImageAnnotation
25 from ...entities
import ImageDataset, ImageDatasetClass
26 from ...threading
import MultithreadedDataProcessor
32 List of all annotation formats supported by Coretex
51 Base class for Coretex Annotation format conversion
63 def __init__(self, datasetName: str, projectId: int, datasetPath: str) ->
None:
64 self._dataset: Final = ImageDataset.createDataset(datasetName, projectId)
65 self._datasetPath: Final = datasetPath
67 def _saveImageAnnotationPair(self, imagePath: str, annotation: CoretexImageAnnotation) ->
None:
68 sample = self._dataset.add(imagePath)
71 if not sample.saveAnnotation(annotation):
72 logging.getLogger(
"coretexpylib").info(
">> [Coretex] Failed to save ImageSample annotation")
75 def _dataSource(self) -> List[Any]:
79 def _extractLabels(self) -> Set[str]:
83 def _extractSingleAnnotation(self, value: Any) ->
None:
88 Converts the dataset to Coretex Format
92 ImageDatasetType -> The converted ImageDataset object
97 classes = ImageDatasetClass.generate(labels)
99 if self._dataset.saveClasses(classes):
100 logging.getLogger(
"coretexpylib").info(
">> [Coretex] Dataset classes saved successfully")
102 logging.getLogger(
"coretexpylib").info(
">> [Coretex] Failed to save dataset classes")
105 MultithreadedDataProcessor(
108 message =
"Converting dataset..."
111 if not self._dataset.finalize():
112 raise ValueError(f
"Failed to finalize dataset \"{self._dataset.name}\"")
ImageDataset convert(self)
None _extractSingleAnnotation(self, Any value)
List[Any] _dataSource(self)
Set[str] _extractLabels(self)