# API reference

0.2.3

### datadreamer

Kind: Package

#### dataset_annotation

Kind: Package

##### aimv2_annotator

Kind: Module

This file uses pre-trained model derived from Apple's software, provided under the
Apple Sample Code License license. The license is available at:

https://developer.apple.com/support/downloads/terms/apple-sample-code/Apple-Sample-Code-License.pdf

In addition, this file and other parts of the repository are licensed under the Apache 2.0
License. By using this file, you agree to comply with the terms of both licenses.

##### clip_annotator

Kind: Module

##### cls_annotator

Kind: Module

##### image_annotator

Kind: Module

##### owlv2_annotator

Kind: Module

##### sam2_annotator

Kind: Module

##### slimsam_annotator

Kind: Module

##### utils

Kind: Module

###### apply_tta(image) -> List[transforms.Compose]: List[transforms.Compose]

Kind: Function

Apply test-time augmentation (TTA) to the given image.

Args:
image: The image to be augmented.

Returns:
list: A list of augmented images.

Note:
Currently, only horizontal flip is enabled. Additional transformations like
vertical flip and color jitter are commented out but can be enabled as needed.

###### convert_binary_mask(mask: np.ndarray, mask_format: str = 'polygon', epsilon_ratio: float = 0.001) -> List[List[int]]:
List[List[int]]

Kind: Function

###### mask_to_rle(mask: np.ndarray) -> dict: dict

Kind: Function

###### mask_to_polygon(mask: np.ndarray, epsilon_ratio: float = 0.001) -> List[List[int]]: List[List[int]]

Kind: Function

Converts a binary mask to a smoothed polygon.

Args:
mask: The binary mask to be converted.
epsilon_ratio: Controls the smoothing level. Higher values mean more smoothing.

Returns:
List: A list of vertices of the polygon.

##### datadreamer.dataset_annotation.AIMv2Annotator(datadreamer.dataset_annotation.ImgClassificationAnnotator)

Kind: Class

A class for image annotation using the AIMv2 model, specializing in image
classification.

Attributes:
model (AutoModel): The AIMv2 model for image-text similarity evaluation.
processor (AutoProcessor): The processor for preparing inputs to the AIMv2 model.
device (str): The device on which the model will run ('cuda' for GPU, 'cpu' for CPU).
size (str): The size of the AIMv2 model to use ('base' or 'large').

Methods:
_init_processor(): Initializes the AIMv2 processor.
_init_model(): Initializes the AIMv2 model.
annotate_batch(image, prompts, conf_threshold, use_tta, synonym_dict): Annotates the given image with bounding boxes and labels.
release(empty_cuda_cache): Releases resources and optionally empties the CUDA cache.

##### datadreamer.dataset_annotation.CLIPAnnotator(datadreamer.dataset_annotation.ImgClassificationAnnotator)

Kind: Class

A class for image annotation using the CLIP model, specializing in image
classification.

Attributes:
model (CLIPModel): The CLIP model for image-text similarity evaluation.
processor (CLIPProcessor): The processor for preparing inputs to the CLIP model.
device (str): The device on which the model will run ('cuda' for GPU, 'cpu' for CPU).
size (str): The size of the CLIP model to use ('base' or 'large').

Methods:
_init_processor(): Initializes the CLIP processor.
_init_model(): Initializes the CLIP model.
annotate_batch(image, prompts, conf_threshold, use_tta, synonym_dict): Annotates the given image with bounding boxes and labels.
release(empty_cuda_cache): Releases resources and optionally empties the CUDA cache.

##### datadreamer.dataset_annotation.ImgClassificationAnnotator(datadreamer.dataset_annotation.BaseAnnotator)

Kind: Class

Base class for image classification annotators using transformers models.

Attributes:
model: The model for image-text similarity evaluation.
processor: The processor for preparing inputs to the model.
device (str): The device on which the model will run ('cuda' for GPU, 'cpu' for CPU).
size (str): The size of the model to use ('base' or 'large').

Methods:
_init_processor(): Initializes the processor.
_init_model(): Initializes the model.
annotate_batch(image, prompts, conf_threshold, use_tta, synonym_dict): Annotates the given image with bounding boxes and labels.
release(empty_cuda_cache): Releases resources and optionally empties the CUDA cache.

###### __init__(self, seed: float = 42, device: str = 'cuda', size: str = 'base')

Kind: Method

Initializes the image classification annotator.

Args:
seed (float): Seed for reproducibility. Defaults to 42.
device (str): The device to run the model on. Defaults to 'cuda'.
size (str): The model size to use.

###### size

Kind: Instance Variable

###### device

Kind: Instance Variable

###### model

Kind: Instance Variable

###### processor

Kind: Instance Variable

###### annotate_batch(self, images: List [ PIL.Image.Image ], objects: List [ str ], conf_threshold: float = 0.1, synonym_dict:
Dict [ str , List [ str ] ] | None = None) -> List[np.ndarray]: List[np.ndarray]

Kind: Method

Annotates images using the CLIP model.

Args:
images: The images to be annotated.
objects: A list of objects (text) to test against the images.
conf_threshold (float, optional): Confidence threshold for the annotations. Defaults to 0.1.
synonym_dict (dict, optional): Dictionary for handling synonyms in labels. Defaults to None.

Returns:
List[np.ndarray]: A list of the annotations for each image.

###### release(self, empty_cuda_cache: bool = False)

Kind: Method

Releases the model and optionally empties the CUDA cache.

Args:
empty_cuda_cache (bool, optional): Whether to empty the CUDA cache. Defaults to False.

##### datadreamer.dataset_annotation.BaseAnnotator(abc.ABC)

Kind: Class

Abstract base class for creating annotators.

Attributes:
seed (float): A seed value to ensure reproducibility in annotation processes.
task_definition (TaskList): An enumeration of the task type. Default is OBJECT_DETECTION,
which can be overridden by subclasses for specific tasks.

Methods:
annotate_batch(): Abstract method to be implemented by subclasses. It should contain
the logic for performing annotation based on the task definition.
release(): Abstract method to be implemented by subclasses. It should contain
the logic for releasing the resources used by the annotator.

###### __init__(self, seed: float, task_definition: TaskList = TaskList.OBJECT_DETECTION)

Kind: Method

###### seed

Kind: Instance Variable

###### task_definition

Kind: Instance Variable

###### annotate_batch(self)

Kind: Method

###### release(self, empty_cuda_cache = False)

Kind: Method

##### datadreamer.dataset_annotation.TaskList(enum.Enum)

Kind: Class

###### CLASSIFICATION: str

Kind: Constant

###### OBJECT_DETECTION: str

Kind: Constant

###### SEGMENTATION: str

Kind: Constant

##### datadreamer.dataset_annotation.OWLv2Annotator(datadreamer.dataset_annotation.BaseAnnotator)

Kind: Class

A class for image annotation using the OWLv2 model, specializing in object
detection.

Attributes:
model (Owlv2ForObjectDetection): The OWLv2 model for object detection.
processor (Owlv2Processor): The processor for the OWLv2 model.
device (str): The device on which the model will run ('cuda' for GPU, 'cpu' for CPU).
size (str): The size of the OWLv2 model to use ('base' or 'large').

Methods:
_init_model(): Initializes the OWLv2 model.
_init_processor(): Initializes the processor for the OWLv2 model.
annotate_batch(image, prompts, conf_threshold, use_tta, synonym_dict): Annotates the given image with bounding boxes and labels.
release(empty_cuda_cache): Releases resources and optionally empties the CUDA cache.

###### __init__(self, seed: float = 42, device: str = 'cuda', size: str = 'base')

Kind: Method

Initializes the OWLv2Annotator with a specific seed and device.

Args:
seed (float): Seed for reproducibility. Defaults to 42.
device (str): The device to run the model on. Defaults to 'cuda'.

###### size

Kind: Instance Variable

###### model

Kind: Instance Variable

###### processor

Kind: Instance Variable

###### device

Kind: Instance Variable

###### annotate_batch(self, images: List [ PIL.Image.Image ], prompts: List [ str ] | List [ PIL.Image.Image ], conf_threshold:
float = 0.1, iou_threshold: float = 0.2, use_tta: bool = False, synonym_dict: Dict [ str , List [ str ] ] | None = None) ->
Tuple[List[np.ndarray], List[np.ndarray], List[np.ndarray]]: Tuple[List[np.ndarray], List[np.ndarray], List[np.ndarray]]

Kind: Method

Annotates images using the OWLv2 model.

Args:
images: The images to be annotated.
prompts: Prompts to guide the annotation.
conf_threshold (float, optional): Confidence threshold for the annotations. Defaults to 0.1.
iou_threshold (float, optional): Intersection over union threshold for non-maximum suppression. Defaults to 0.2.
use_tta (bool, optional): Flag to apply test-time augmentation. Defaults to False.
synonym_dict (dict, optional): Dictionary for handling synonyms in labels. Defaults to None.

Returns:
tuple: A tuple containing the final bounding boxes, scores, and labels for the annotations.

###### release(self, empty_cuda_cache: bool = False)

Kind: Method

Releases the model and optionally empties the CUDA cache.

Args:
empty_cuda_cache (bool, optional): Whether to empty the CUDA cache. Defaults to False.

##### datadreamer.dataset_annotation.SAM2Annotator(datadreamer.dataset_annotation.BaseAnnotator)

Kind: Class

A class for image annotation using the SAM2.1 model, specializing in instance
segmentation.

Attributes:
model (SAM2ImagePredictor): The SAM2.1 model for instance segmentation.
device (str): The device on which the model will run ('cuda' for GPU, 'cpu' for CPU).
size (str): The size of the SAM model to use ('base' or 'large').

Methods:
_init_model(): Initializes the SAM2.1 model.
annotate_batch(image, prompts, conf_threshold, use_tta, synonym_dict): Annotates the given image with bounding boxes and labels.
release(empty_cuda_cache): Releases resources and optionally empties the CUDA cache.

###### __init__(self, seed: float = 42, device: str = 'cuda', size: str = 'base', mask_format: str = 'rle')

Kind: Method

Initializes the SAM2Annotator.

Args:
seed (float): Seed for reproducibility. Defaults to 42.
device (str): The device to run the model on. Defaults to 'cuda'.
size (str): The size of the SAM2.1 model to use ('base' or 'large').
mask_format (str): The format of the output masks ('rle' or 'polyline').

###### size

Kind: Instance Variable

###### device

Kind: Instance Variable

###### model

Kind: Instance Variable

###### dtype

Kind: Instance Variable

###### mask_format

Kind: Instance Variable

###### annotate_batch(self, images: List [ PIL.Image.Image ], boxes_batch: List [ np.ndarray ], conf_threshold: float = 0.2) ->
List[List[List[float]]]|List[List[dict]]: List[List[List[float]]]|List[List[dict]]

Kind: Method

Annotates images for the task of instance segmentation using the SAM2.1
model.

Args:
images: The images to be annotated.
boxes_batch: The bounding boxes of found objects.
conf_threshold (float, optional): Confidence threshold for the annotations. Defaults to 0.2.

Returns:
List: A list containing masks.

###### release(self, empty_cuda_cache: bool = False)

Kind: Method

Releases the model and optionally empties the CUDA cache.

Args:
empty_cuda_cache (bool, optional): Whether to empty the CUDA cache. Defaults to False.

##### datadreamer.dataset_annotation.SlimSAMAnnotator(datadreamer.dataset_annotation.BaseAnnotator)

Kind: Class

A class for image annotation using the SlimSAM model, specializing in instance
segmentation.

Attributes:
model (SAM): The SAM model for instance segmentation.
processor (SamProcessor): The processor for the SAM model.
device (str): The device on which the model will run ('cuda' for GPU, 'cpu' for CPU).
size (str): The size of the SAM model to use ('base' or 'large').

Methods:
_init_model(): Initializes the SAM model.
_init_processor(): Initializes the processor for the SAM model.
annotate_batch(image, prompts, conf_threshold, use_tta, synonym_dict): Annotates the given image with bounding boxes and labels.
release(empty_cuda_cache): Releases resources and optionally empties the CUDA cache.

###### __init__(self, seed: float = 42, device: str = 'cuda', size: str = 'base', mask_format: str = 'rle')

Kind: Method

Initializes the SlimSAMAnnotator.

Args:
seed (float): Seed for reproducibility. Defaults to 42.
device (str): The device to run the model on. Defaults to 'cuda'.
size (str): The size of the SAM model to use ('base' or 'large').
mask_format (str): The format of the output masks ('rle' or 'polyline').

###### size

Kind: Instance Variable

###### model

Kind: Instance Variable

###### processor

Kind: Instance Variable

###### device

Kind: Instance Variable

###### mask_format

Kind: Instance Variable

###### annotate_batch(self, images: List [ PIL.Image.Image ], boxes_batch: List [ np.ndarray ], conf_threshold: float = 0.2) ->
List[List[List[float]]]: List[List[List[float]]]

Kind: Method

Annotates images for the task of instance segmentation using the SlimSAM
model.

Args:
images: The images to be annotated.
boxes_batch: The bounding boxes of found objects.
conf_threshold (float, optional): Confidence threshold for the annotations. Defaults to 0.2.

Returns:
List: A list containing the final segment masks represented as a polygon.

###### release(self, empty_cuda_cache: bool = False)

Kind: Method

Releases the model and optionally empties the CUDA cache.

Args:
empty_cuda_cache (bool, optional): Whether to empty the CUDA cache. Defaults to False.

#### image_generation

Kind: Package

##### clip_image_tester

Kind: Module

###### datadreamer.image_generation.clip_image_tester.ClipImageTester

Kind: Class

A class for testing images against a set of textual objects using the CLIP model.

Attributes:
clip (CLIPModel): The CLIP model for image-text similarity evaluation.
clip_processor (CLIPProcessor): The processor for preparing inputs to the CLIP model.
device (str): The device on which the model will run ('cuda' for GPU, 'cpu' for CPU).

Methods:
test_image(image, objects, conf_threshold): Tests the given image against a list of objects.
release(empty_cuda_cache): Releases resources and optionally empties the CUDA cache.

###### __init__(self, device: str = 'cuda')

Kind: Method

Initializes the ClipImageTester with the CLIP model and processor.

###### clip

Kind: Instance Variable

###### clip_processor

Kind: Instance Variable

###### device

Kind: Instance Variable

###### test_image(self, image: Image.Image, objects: List [ str ], conf_threshold: float = 0.05) -> Tuple[bool, torch.Tensor,
int]: Tuple[bool, torch.Tensor, int]

Kind: Method

Tests the generated image against a set of objects using the CLIP model.

Args:
image (Image.Image): The image to be tested.
objects (List[str]): A list of objects (text) to test against the image.
conf_threshold (float): Confidence threshold for considering an object as present.

Returns:
tuple: A tuple containing a boolean indicating if the image passes the test,
the probabilities of the objects, and the number of objects that passed the test.

###### test_images_batch(self, images: List [ Image.Image ], objects: List [ List [ str ] ], conf_threshold: float = 0.05) ->
Tuple[List[bool], List[torch.Tensor], List[int]]: Tuple[List[bool], List[torch.Tensor], List[int]]

Kind: Method

Tests the generated images against a set of objects using the CLIP model.

Args:
images (List[Image.Image]): The images to be tested.
objects (List[List[str]]): A list of objects (text) to test against the images.
conf_threshold (float, optional): Confidence threshold for considering an object as present. Defaults to 0.05.

Returns:
Tuple[List[bool], List[torch.Tensor], List[int]]: A tuple containing a list of booleans indicating if the images pass the test,
a list of probabilities of the objects, and a list of the number of objects that passed the test.

###### release(self, empty_cuda_cache = False)

Kind: Method

Releases the model and optionally empties the CUDA cache.

Args:
empty_cuda_cache (bool, optional): Whether to empty the CUDA cache. Defaults to False.

##### image_generator

Kind: Module

###### datadreamer.image_generation.image_generator.ImageGenerator

Kind: Class

A class for generating images based on textual prompts, with optional CLIP model
testing.

Attributes:
prompt_prefix (str): Optional prefix to add to every prompt.
prompt_suffix (str): Optional suffix to add to every prompt, e.g., for adding details like resolution.
negative_prompt (str): A string of negative prompts to guide the generation away from certain features.
use_clip_image_tester (bool): Flag to use CLIP model testing for generated images.
image_tester_patience (int): The number of attempts to generate an image that passes CLIP testing.
batch_size (int): The number of images to generate in each batch.
seed (float): Seed for reproducibility.
clip_image_tester (ClipImageTester): Instance of ClipImageTester if use_clip_image_tester is True.
device (str): The device on which the model will run ('cuda' for GPU, 'cpu' for CPU).

Methods:
set_seed(seed): Sets the seed for random number generators.
generate_images(prompts, prompt_objects): Generates images based on provided prompts and optional object prompts.
release(empty_cuda_cache): Releases resources and optionally empties the CUDA cache. (Abstract method)
generate_images_batch(prompts, negative_prompt, prompt_objects): Generates a batch of images based on the provided prompts.
Abstract method)

Note:
The actual model for image generation needs to be defined in the subclass.

###### __init__(self, prompt_prefix: Optional [ str ] = '', prompt_suffix: Optional [ str ] = ', hd, 8k, highly detailed',
negative_prompt: Optional [ str ] = 'cartoon, blue skin, painting, scrispture, golden, illustration, worst quality, low quality,
normal quality:2, unrealistic dream, low resolution, static, sd character, low quality, low resolution, greyscale, monochrome,
nose, cropped, lowres, jpeg artifacts, deformed iris, deformed pupils, bad eyes, semi-realistic worst quality, bad lips, deformed
mouth, deformed face, deformed fingers, bad anatomy', use_clip_image_tester: Optional [ bool ] = False, image_tester_patience:
Optional [ int ] = 1, batch_size: Optional [ int ] = 1, seed: Optional [ float ] = 42, device: str = 'cuda')

Kind: Method

Initializes the ImageGenerator with the specified settings.

###### prompt_prefix

Kind: Instance Variable

###### prompt_suffix

Kind: Instance Variable

###### negative_prompt

Kind: Instance Variable

###### seed

Kind: Instance Variable

###### use_clip_image_tester

Kind: Instance Variable

###### image_tester_patience

Kind: Instance Variable

###### batch_size

Kind: Instance Variable

###### device

Kind: Instance Variable

###### clip_image_tester

Kind: Instance Variable

###### set_seed(seed: int)

Kind: Static Method

Sets the seed for random number generators in Python and PyTorch.

Args:
seed (int): The seed value to set.

###### generate_images(self, prompts: Union [ str , List [ str ] ], prompt_objects: Optional [ List [ List [ str ] ] ] = None) ->
List[Image.Image]: List[Image.Image]

Kind: Method

Generates images based on the provided prompts and optional object prompts.

Args:
prompts (Union[str, List[str]]): Single prompt or a list of prompts to guide the image generation.
prompt_objects (Optional[List[List[str]]]): Optional list of objects for each prompt for CLIP model testing.

Yields:
List[Image.Image]: A batch of generated images.

###### release(self, empty_cuda_cache = False)

Kind: Method

Releases resources and optionally empties the CUDA cache.

###### generate_images_batch(self, prompts: List [ str ], negative_prompt: str, prompt_objects: Optional [ List [ List [ str ] ] ]
= None) -> List[Image.Image]: List[Image.Image]

Kind: Method

Generates a batch of images based on the provided prompts.

Args:
prompts (List[str]): A list of positive prompts to guide image generation.
negative_prompt (str): The negative prompt to avoid certain features in the image.
prompt_objects (Optional[List[List[str]]]): Optional list of objects to be used in CLIP model testing.

Returns:
List[Image.Image]: A list of generated images.

##### sdxl_image_generator

Kind: Module

##### sdxl_lightning_image_generator

Kind: Module

##### sdxl_turbo_image_generator

Kind: Module

##### shuttle_3_image_generator

Kind: Module

##### datadreamer.image_generation.StableDiffusionImageGenerator(datadreamer.image_generation.image_generator.ImageGenerator)

Kind: Class

A subclass of ImageGenerator that uses the Stable Diffusion model for image
generation.

Attributes:
base (DiffusionPipeline): The base Stable Diffusion model for initial image generation.
refiner (DiffusionPipeline): The refiner Stable Diffusion model for enhancing generated images.
base_processor (Compel): Processor for the base model.
refiner_processor (Compel): Processor for the refiner model.

Methods:
_init_gen_model(): Initializes the generative models for image generation.
_init_processor(): Initializes the processors for the models.
generate_images_batch(prompts, negative_prompt, prompt_objects): Generates a batch of images based on the provided prompts.
release(empty_cuda_cache): Releases resources and optionally empties the CUDA cache.

###### __init__(self, args, kwargs)

Kind: Method

Initializes the StableDiffusionImageGenerator with the given arguments.

###### base

Kind: Instance Variable

###### refiner

Kind: Instance Variable

###### base_processor

Kind: Instance Variable

###### refiner_processor

Kind: Instance Variable

###### generate_images_batch(self, prompts: List [ str ], negative_prompt: str, prompt_objects: Optional [ List [ List [ str ] ] ]
= None) -> List[Image.Image]: List[Image.Image]

Kind: Method

Generates a batch of images based on the provided prompts.

Args:
prompts (List[str]): A list of positive prompts to guide image generation.
negative_prompt (str): The negative prompt to avoid certain features in the image.
prompt_objects (Optional[List[List[str]]]): Optional list of objects to be used in CLIP model testing.

Returns:
List[Image.Image]: A list of generated images.

###### release(self, empty_cuda_cache = False)

Kind: Method

Releases the models and optionally empties the CUDA cache.

#####
datadreamer.image_generation.StableDiffusionLightningImageGenerator(datadreamer.image_generation.image_generator.ImageGenerator)

Kind: Class

A subclass of ImageGenerator specifically designed to use the Stable Diffusion
Lightning model for faster image generation.

Attributes:
pipe (StableDiffusionXLPipeline): The Stable Diffusion Lightning model for image generation.

Methods:
_init_gen_model(): Initializes the Stable Diffusion Lightning model.
_init_compel(): Initializes the Compel model for text prompt weighting.
generate_images_batch(prompts, negative_prompt, prompt_objects): Generates a batch of images based on the provided prompts.
release(empty_cuda_cache): Releases resources and optionally empties the CUDA cache.

###### __init__(self, args, kwargs)

Kind: Method

Initializes the StableDiffusionLightningImageGenerator with the given
arguments.

###### pipe

Kind: Instance Variable

###### compel

Kind: Instance Variable

###### generate_images_batch(self, prompts: List [ str ], negative_prompt: str, prompt_objects: Optional [ List [ List [ str ] ] ]
= None) -> List[Image.Image]: List[Image.Image]

Kind: Method

Generates a batch of images using the Stable Diffusion Lightning model based
on the provided prompts.

Args:
prompts (List[str]): A list of positive prompts to guide image generation.
negative_prompt (str): The negative prompt to avoid certain features in the image.
prompt_objects (Optional[List[List[str]]]): Optional list of objects for each prompt for CLIP model testing.

Returns:
List[Image.Image]: A list of generated images.

###### release(self, empty_cuda_cache = False)

Kind: Method

Releases the model and optionally empties the CUDA cache.

##### datadreamer.image_generation.StableDiffusionTurboImageGenerator(datadreamer.image_generation.image_generator.ImageGenerator)

Kind: Class

A subclass of ImageGenerator specifically designed to use the Stable Diffusion
Turbo model for faster image generation.

Attributes:
base (AutoPipelineForText2Image): The Stable Diffusion Turbo model for image generation.

Methods:
_init_gen_model(): Initializes the Stable Diffusion Turbo model.
generate_images_batch(prompts, negative_prompt, prompt_objects): Generates a batch of images based on the provided prompts.
release(empty_cuda_cache): Releases resources and optionally empties the CUDA cache.

###### __init__(self, args, kwargs)

Kind: Method

Initializes the StableDiffusionTurboImageGenerator with the given
arguments.

###### base

Kind: Instance Variable

###### compel

Kind: Instance Variable

###### generate_images_batch(self, prompts: List [ str ], negative_prompt: str, prompt_objects: Optional [ List [ List [ str ] ] ]
= None, batch_size: int = 1) -> List[Image.Image]: List[Image.Image]

Kind: Method

Generates a batch of images using the Stable Diffusion Turbo model based on
the provided prompts.

Args:
prompts (List[str]): A list of positive prompts to guide image generation.
negative_prompt (str): The negative prompt to avoid certain features in the image.
prompt_objects (Optional[List[List[str]]]): Optional list of objects for each prompt for CLIP model testing.
batch_size (int): The number of images to generate in each batch.

Returns:
List[Image.Image]: A list of generated images.

###### release(self, empty_cuda_cache = False)

Kind: Method

Releases the model and optionally empties the CUDA cache.

##### datadreamer.image_generation.Shuttle3DiffusionImageGenerator(datadreamer.image_generation.image_generator.ImageGenerator)

Kind: Class

A subclass of ImageGenerator specifically designed to use the Shuttle 3 Diffusion
model for faster image generation.

Attributes:
pipe (DiffusionPipeline): The Shuttle 3 Diffusion model for image generation.

Methods:
_init_gen_model(): Initializes the Shuttle 3 Diffusion model.
generate_images_batch(prompts, negative_prompt, prompt_objects): Generates a batch of images based on the provided prompts.
release(empty_cuda_cache): Releases resources and optionally empties the CUDA cache.

###### __init__(self, args, kwargs)

Kind: Method

Initializes the Shuttle3DiffusionImageGenerator with the given arguments.

###### pipe

Kind: Instance Variable

###### generate_images_batch(self, prompts: List [ str ], negative_prompt: str, prompt_objects: Optional [ List [ List [ str ] ] ]
= None) -> List[Image.Image]: List[Image.Image]

Kind: Method

Generates a batch of images using the Shuttle 3 Diffusion model based on the
provided prompts.

Args:
prompts (List[str]): A list of positive prompts to guide image generation.
negative_prompt (str): The negative prompt to avoid certain features in the image.
prompt_objects (Optional[List[List[str]]]): Optional list of objects for each prompt for CLIP model testing.

Returns:
List[Image.Image]: A list of generated images.

###### release(self, empty_cuda_cache = False)

Kind: Method

Releases the model and optionally empties the CUDA cache.

#### pipelines

Kind: Package

##### generate_dataset_from_scratch

Kind: Module

###### prompt_generators

Kind: Variable

###### synonym_generators

Kind: Variable

###### image_generators

Kind: Variable

###### det_annotators

Kind: Variable

###### clf_annotators

Kind: Variable

###### inst_seg_annotators

Kind: Variable

###### inst_seg_detectors

Kind: Variable

###### parse_args()

Kind: Function

###### check_args(args)

Kind: Function

###### main()

Kind: Function

#### prompt_generation

Kind: Package

##### lm_prompt_generator

Kind: Module

##### lm_synonym_generator

Kind: Module

##### profanity_filter

Kind: Module

##### prompt_generator

Kind: Module

###### datadreamer.prompt_generation.prompt_generator.PromptGenerator(abc.ABC)

Kind: Class

Abstract base class for prompt generation.

Attributes:
class_names (List[str]): List of class names or objects for prompt generation.
prompts_number (int): Number of prompts to generate.
num_objects_range (Optional[List[int]]): Range for the number of objects to include in prompts.
seed (Optional[float]): Seed for randomization.
device (str): Device to run the prompt generator on ('cuda' for GPU, 'cpu' for CPU).
quantization (str): Quantization type for the prompt generator.

Methods:
set_seed(seed): Sets the random seed for consistent prompt generation.
save_prompts(prompts, save_path): Saves generated prompts to a JSON file.
generate_prompts(): Abstract method to generate prompts (must be implemented in subclasses).
release(empty_cuda_cache): Abstract method to release resources (must be implemented in subclasses).

###### __init__(self, class_names: List [ str ], prompts_number: int = 10, num_objects_range: Optional [ List [ int ] ] = None,
batch_size: int = 1, seed: Optional [ float ] = None, device: str = 'cuda', quantization: Optional [ Literal [ ' none ' , ' 4bit '
] ] = 'none')

Kind: Method

Initializes the PromptGenerator with class names and other settings.

###### class_names

Kind: Instance Variable

###### prompts_number

Kind: Instance Variable

###### num_objects_range

Kind: Instance Variable

###### batch_size

Kind: Instance Variable

###### seed

Kind: Instance Variable

###### device

Kind: Instance Variable

###### quantization

Kind: Instance Variable

###### set_seed(seed: int)

Kind: Static Method

Sets the random seed for consistent prompt generation.

Args:
seed (int): The random seed.

###### save_prompts(self, prompts: List [ str ], save_path: str)

Kind: Method

Saves generated prompts to a JSON file.

Args:
prompts (List[str]): List of generated prompts.
save_path (str): Path to save the prompts JSON file.

###### generate_prompts(self) -> List[str]: List[str]

Kind: Method

Abstract method to generate prompts (must be implemented in subclasses).

Returns:
List[str]: A list of generated prompts.

###### release(self, empty_cuda_cache = False)

Kind: Method

Abstract method to release resources (must be implemented in subclasses).

##### qwen2_lm_prompt_generator

Kind: Module

##### simple_prompt_generator

Kind: Module

##### synonym_generator

Kind: Module

###### datadreamer.prompt_generation.synonym_generator.SynonymGenerator(abc.ABC)

Kind: Class

Abstract base class for synonym generation.

Attributes:
synonyms_number (int): Number of synonyms to generate for each word.
seed (Optional[float]): Seed for randomization.
device (str): Device to run the prompt generator on ('cuda' for GPU, 'cpu' for CPU).

Methods:
_init_lang_model(): Initializes the language model and tokenizer.
_generate_synonyms(prompt_text): Generates synonyms based on a given prompt text.
_extract_synonyms(text): Extracts synonyms from a text containing synonyms.
_create_prompt_text(word): Creates a prompt text for generating synonyms for a given word.
generate_synonyms_for_list(words): Generates synonyms for a list of words and returns them in a dictionary.
generate_synonyms(word): Generates synonyms for a single word and returns them in a list.
save_synonyms(synonyms, save_path): Saves the generated synonyms to a JSON file.
release(empty_cuda_cache): Releases resources (no action is taken in this implementation).

###### __init__(self, synonyms_number: int = 3, seed: Optional [ float ] = 42, device: str = 'cuda')

Kind: Method

Initializes the SynonymGenerator with parameters.

###### synonyms_number

Kind: Instance Variable

###### seed

Kind: Instance Variable

###### device

Kind: Instance Variable

###### generate_synonyms_for_list(self, words: List [ str ]) -> Dict: Dict

Kind: Method

Generates synonyms for a list of words and returns them in a dictionary.

Args:
words (List[str]): List of words for which synonyms are generated.

Returns:
dict: A dictionary where each word is associated with a list of its most common synonyms.

###### save_synonyms(self, synonyms: Dict, save_path: str)

Kind: Method

Saves the generated synonyms to a JSON file.

Args:
synonyms: The synonyms to save (typically a dictionary).
save_path (str): The path to the JSON file where synonyms will be saved.

###### generate_synonyms(self, word: str) -> List[str]: List[str]

Kind: Method

Generates synonyms for a single word and returns them in a list.

Args:
word (str): The word for which synonyms are generated.

Returns:
List[str]: A list of generated synonyms for the word.

###### release(self, empty_cuda_cache = False)

Kind: Method

Abstract method to release resources (must be implemented in subclasses).

##### tinyllama_lm_prompt_generator

Kind: Module

##### wordnet_synonym_generator

Kind: Module

##### datadreamer.prompt_generation.LMPromptGenerator(datadreamer.prompt_generation.prompt_generator.PromptGenerator)

Kind: Class

A language model-based prompt generator class, extending PromptGenerator.

Attributes:
device (str): Device to run the language model on ('cuda' for GPU, 'cpu' for CPU).
num_objects_range (List[int]): Range for number of objects in a single image.
model (AutoModelForCausalLM): The pre-trained causal language model for generating prompts.
tokenizer (AutoTokenizer): The tokenizer for the pre-trained language model.
pipeline (pipeline): The HuggingFace pipeline for generating text.

Methods:
_init_lang_model(): Initializes the language model and tokenizer.
_remove_incomplete_sentence(text): Removes incomplete sentences from the generated prompt.
_create_lm_prompt_text(selected_objects): Creates a text prompt for the language model.
_create_lm_prompt_text_batch(selected_objects_batch): Creates a batch of text prompts for the language model.
_postprocess_prompt(prompt): Post-processes the generated prompt.
_test_prompt(prompt, selected_objects): Tests if the generated prompt is valid.
generate_prompts_batch(prompt_texts_batch): Generates a batch of prompts using the language model.
generate_prompts(): Generates a list of prompts based on the class names.
release(empty_cuda_cache): Releases resources and optionally empties the CUDA cache.

###### __init__(self, class_names: List [ str ], prompts_number: int = 10, num_objects_range: Optional [ List [ int ] ] = None,
batch_size: int = 1, seed: Optional [ float ] = 42, device: str = 'cuda', quantization: Optional [ Literal [ ' none ' , ' 4bit ' ]
] = 'none')

Kind: Method

Initializes the LMPromptGenerator with class names and other settings.

###### model

Kind: Instance Variable

###### tokenizer

Kind: Instance Variable

###### pipeline

Kind: Instance Variable

###### generate_prompts_batch(self, prompt_texts_batch: List [ str ]) -> List[str]: List[str]

Kind: Method

Generates a list of prompts using the language model.

Args:
prompt_texts_batch (List[str]): List of text prompts for the language model.

Returns:
List[str]: List of generated prompts.

###### generate_prompts(self) -> List[str]: List[str]

Kind: Method

Generates a list of text prompts based on the class names.

Returns:
List[str]: A list of generated prompts.

###### release(self, empty_cuda_cache = False)

Kind: Method

Releases the model and optionally empties the CUDA cache.

##### datadreamer.prompt_generation.LMSynonymGenerator(datadreamer.prompt_generation.synonym_generator.SynonymGenerator)

Kind: Class

Synonym generator that generates synonyms for a list of words using a language
model.

Args:
synonyms_number (int): Number of synonyms to generate for each word.
seed (Optional[float]): Seed for randomization.
device (str): Device for model inference (default is "cuda").

Methods:
_init_lang_model(): Initializes the language model and tokenizer.
_generate_synonyms(prompt_text): Generates synonyms based on a given prompt text.
_extract_synonyms(text): Extracts synonyms from a text containing synonyms.
_create_prompt_text(word): Creates a prompt text for generating synonyms for a given word.
generate_synonyms(word): Generates synonyms for a single word and returns them in a list.
release(empty_cuda_cache): Releases resources (no action is taken in this implementation).

###### __init__(self, synonyms_number: int = 3, seed: Optional [ float ] = 42, device: str = 'cuda')

Kind: Method

Initializes the SynonymGenerator with parameters.

###### model

Kind: Instance Variable

###### tokenizer

Kind: Instance Variable

###### pipeline

Kind: Instance Variable

###### generate_synonyms(self, word: str) -> List[str]: List[str]

Kind: Method

Generates synonyms for a single word and returns them in a list.

Args:
word (str): The word for which synonyms are generated.

Returns:
List[str]: A list of generated synonyms for the word.

###### release(self, empty_cuda_cache = False)

Kind: Method

Releases resources and optionally empties the CUDA cache.

Args:
empty_cuda_cache (bool): Whether to empty the CUDA cache (default is False).

##### datadreamer.prompt_generation.ProfanityFilter

Kind: Class

Class for filtering bad words from texts and checking if texts are safe.

Attributes:
device (str): Device to run the language model on ('cuda' for GPU, 'cpu' for CPU).
use_lm (bool): Whether to use a language model for checking text safety.
seed (Optional[float]): Seed for randomization.
model (AutoModelForCausalLM): The pre-trained causal language model for checking text safety.
tokenizer (AutoTokenizer): The tokenizer for the pre-trained language model.

Methods:
set_seed(seed): Sets the random seed for consistent prompt generation.
_init_lang_model(): Initializes the language model and tokenizer.
_contains_bad_words(texts): Checks if a list of texts contain bad words.
_check_lm_safety(text): Checks if a text is safe using a language model.
is_safe(classes): Checks if a list of classes is safe.
release(empty_cuda_cache): Releases the model and optionally empties the CUDA cache.

###### LLM_PROMPT: str

Kind: Constant

###### __init__(self, device: str = 'cuda', use_lm: bool = False, seed: Optional [ float ] = 42)

Kind: Method

Initializes the ProfanityFilter with parameters.

###### seed

Kind: Instance Variable

###### device

Kind: Instance Variable

###### use_lm

Kind: Instance Variable

###### model

Kind: Instance Variable

###### tokenizer

Kind: Instance Variable

###### set_seed(seed: int)

Kind: Static Method

Sets the random seed for consistent prompt generation.

Args:
seed (int): The random seed.

###### is_safe(self, classes: List [ str ]) -> bool: bool

Kind: Method

Checks if a list of classes is safe.

Args:
classes (List[str]): List of classes to check for safety.

Returns:
bool: True if the classes are safe, False otherwise.

###### release(self, empty_cuda_cache = False)

Kind: Method

Releases the model and optionally empties the CUDA cache.

##### datadreamer.prompt_generation.Qwen2LMPromptGenerator(datadreamer.prompt_generation.LMPromptGenerator)

Kind: Class

A language model-based prompt generator class, extending PromptGenerator.

Attributes:
device (str): Device to run the language model on ('cuda' for GPU, 'cpu' for CPU).
model (AutoModelForCausalLM): The pre-trained causal language model for generating prompts.
tokenizer (AutoTokenizer): The tokenizer for the pre-trained language model.
pipeline (pipeline): The HuggingFace pipeline for generating text.

Methods:
_init_lang_model(): Initializes the language model and tokenizer.
_remove_caption_sentences(text): Removes caption sentences from the generated prompt.
_create_lm_prompt_text(selected_objects): Creates a text prompt for the language model.
_postprocess_prompt(prompt): Post-processes the generated prompt.
generate_prompts_batch(prompt_texts_batch): Generates a batch of prompts using the language model.

###### __init__(self, class_names: List [ str ], prompts_number: int = 10, num_objects_range: Optional [ List [ int ] ] = None,
batch_size: int = 1, seed: Optional [ float ] = 42, device: str = 'cuda', quantization: Optional [ Literal [ ' none ' , ' 4bit ' ]
] = 'none')

Kind: Method

Initializes the LMPromptGenerator with class names and other settings.

###### generate_prompts_batch(self, prompt_texts_batch: List [ str ]) -> List[str]: List[str]

Kind: Method

Generates a list of prompts using the language model.

Args:
prompt_texts_batch (List[str]): List of text prompts for the language model.

Returns:
List[str]: List of generated prompts.

##### datadreamer.prompt_generation.SimplePromptGenerator(datadreamer.prompt_generation.prompt_generator.PromptGenerator)

Kind: Class

Prompt generator that creates simple prompts for text generation tasks.

Args:
class_names (List[str]): List of class names or objects for prompt generation.
prompts_number (int): Number of prompts to generate.
num_objects_range (Optional[List[int]]): Range for the number of objects to include in prompts.
seed (Optional[float]): Seed for randomization.

Methods:
generate_prompts(): Generates a list of simple prompts.
generate_prompt(selected_objects): Generates a single simple prompt based on selected objects.
release(empty_cuda_cache): Releases resources (no action is taken in this implementation).

###### __init__(self, args, kwargs)

Kind: Method

Initializes the SimplePromptGenerator with class names and other settings.

###### generate_prompts(self) -> List[str]: List[str]

Kind: Method

Generates a list of simple prompts.

Returns:
List[str]: A list of generated prompts in the form of "A photo of a {selected_objects}".

###### generate_prompt(self, selected_objects: List [ str ]) -> str: str

Kind: Method

Generates a single simple prompt based on selected objects.

Args:
selected_objects (List[str]): List of selected objects to include in the prompt.

Returns:
str: A simple prompt in the form of "A photo of a {selected_objects}".

###### release(self, empty_cuda_cache = False)

Kind: Method

Releases resources (no action is taken in this implementation).

##### datadreamer.prompt_generation.TinyLlamaLMPromptGenerator(datadreamer.prompt_generation.LMPromptGenerator)

Kind: Class

A language model-based prompt generator class, extending PromptGenerator.

Attributes:
device (str): Device to run the language model on ('cuda' for GPU, 'cpu' for CPU).
model (AutoModelForCausalLM): The pre-trained causal language model for generating prompts.
tokenizer (AutoTokenizer): The tokenizer for the pre-trained language model.
pipeline (pipeline): The HuggingFace pipeline for generating text.

Methods:
_init_lang_model(): Initializes the language model and tokenizer.
_remove_caption_sentences(text): Removes caption sentences from the generated prompt.
_create_lm_prompt_text(selected_objects): Creates a text prompt for the language model.
_postprocess_prompt(prompt): Post-processes the generated prompt.
generate_prompts_batch(prompt_texts_batch): Generates a batch of prompts using the language model.

###### __init__(self, class_names: List [ str ], prompts_number: int = 10, num_objects_range: Optional [ List [ int ] ] = None,
batch_size: int = 1, seed: Optional [ float ] = 42, device: str = 'cuda', quantization: Optional [ Literal [ ' none ' , ' 4bit ' ]
] = 'none')

Kind: Method

Initializes the LMPromptGenerator with class names and other settings.

###### generate_prompts_batch(self, prompt_texts_batch: List [ str ]) -> List[str]: List[str]

Kind: Method

Generates a list of prompts using the language model.

Args:
prompt_texts_batch (List[str]): List of text prompts for the language model.

Returns:
List[str]: List of generated prompts.

##### datadreamer.prompt_generation.WordNetSynonymGenerator(datadreamer.prompt_generation.synonym_generator.SynonymGenerator)

Kind: Class

Synonym generator that generates synonyms for a list of words using WordNet.

Args:
synonyms_number (int): Number of synonyms to generate for each word.
seed (Optional[float]): Seed for randomization.
device (str): Device to run the prompt generator on ('cuda' for GPU, 'cpu' for CPU).

Methods:
generate_synonyms(word): Generates synonyms for a single word and returns them in a list.

###### __init__(self, synonyms_number: int = 3, seed: Optional [ float ] = 42, device: str = 'cuda')

Kind: Method

Initializes the SynonymGenerator with parameters.

###### generate_synonyms(self, word: str) -> List[str]: List[str]

Kind: Method

Generates synonyms for a single word and returns them in a list.

Args:
word (str): The word for which synonyms are generated.

Returns:
List[str]: A list of generated synonyms for the word.

###### release(self, empty_cuda_cache: bool = False)

Kind: Method

Releases resources (no action is taken in this implementation).

#### utils

Kind: Package

##### bad_words

Kind: Module

###### BAD_WORDS_LIST: list[str]

Kind: Constant

##### base_converter

Kind: Module

##### coco_converter

Kind: Module

##### config

Kind: Module

##### convert_dataset

Kind: Module

###### convert_dataset(input_dir: str, output_dir: str, dataset_format: str, split_ratios: List [ float ], dataset_plugin:
Optional [ str ] = None, dataset_name: Optional [ str ] = None, is_instance_segmentation: bool = False, keep_unlabeled_images:
bool = False, copy_files: bool = True, seed: int = 42)

Kind: Function

Converts a dataset from one format to another.

Args:
input_dir (str): Directory containing the images and annotations.
output_dir (str): Directory where the processed dataset will be saved.
dataset_format (str): Format of the dataset. Can be 'yolo', 'coco', 'voc', 'luxonis-dataset', or 'cls-single'.
split_ratios (lis of float): List of ratios for train, val, and test splits.
dataset_plugin (str, optional): Plugin for Luxonis dataset. Defaults to None.
dataset_name (str, optional): Name of the Luxonis dataset. Defaults to None.
is_instance_segmentation (bool, optional): Whether the dataset is for instance segmentation. Defaults to False.
keep_unlabeled_images (bool, optional): Whether to keep images with no annotations. Defaults to False.
copy_files (bool, optional): Whether to copy the files to the output directory. Defaults to True.
seed (int, optional): Random seed. Defaults to 42.

No return value.

###### main()

Kind: Function

##### dataset_utils

Kind: Module

###### save_annotations_to_json(image_paths, labels_list, boxes_list = None, masks_list = None, class_names = None, save_dir =
None, file_name = 'annotations.json')

Kind: Function

Saves annotations to a JSON file.

Args:
image_paths (list): List of image paths.
labels_list (list): List of labels.
boxes_list (list, optional): List of bounding boxes. Defaults to None.
masks_list (list, optional): List of instance segmentation masks. Defaults to None.
class_names (list, optional): List of class names. Defaults to None.
save_dir (str, optional): Directory to save the JSON file. Defaults to None.
file_name (str, optional): Name of the JSON file. Defaults to 'annotations.json'.

No return value.

##### luxonis_dataset_converter

Kind: Module

##### merge_raw_datasets

Kind: Module

###### merge_datasets(input_dirs: List [ str ], output_dir: str, copy_files: bool = True)

Kind: Function

Merges multiple raw datasets into a single dataset.

Args:
input_dirs (List[str]): A list of input directories containing raw datasets.
output_dir (str): The output directory where the merged dataset will be saved.
copy_files (bool, optional): Whether to copy the files from the input directories
to the output directory. Defaults to True.

No return value.

###### main()

Kind: Function

##### nms

Kind: Module

###### xywh2xyxy(x)

Kind: Function

Convert boxes with shape [n, 4] from [x, y, w, h] to [x1, y1, x2, y2] where x1y1
is top-left, x2y2=bottom-right.

###### non_max_suppression(prediction, conf_thres = 0.25, iou_thres = 0.45, classes = None, agnostic = False, multi_label = False,
max_det = 300) -> List[np.ndarray]: List[np.ndarray]

Kind: Function

Runs Non-Maximum Suppression (NMS) on inference results.
This code is borrowed from:
https://github.com/ultralytics/yolov5/blob/47233e1698b89fc437a4fb9463c815e9171be955/utils/general.py#L775
Args:
prediction: (tensor), with shape [N, 5 + num_classes], N is the number of bboxes.
conf_thres: (float) confidence threshold.
iou_thres: (float) iou threshold.
classes: (None or list[int]), if a list is provided, nms only keep the classes you provide.
agnostic: (bool), when it is set to True, we do class-independent nms, otherwise, different class would do nms respectively.
multi_label: (bool), when it is set to True, one box can have multi labels, otherwise, one box only huave one label.
max_det:(int), max number of output bboxes.

Returns:
list of detections, echo item is one tensor with shape (num_boxes, 6), 6 is for [xyxy, conf, cls].

##### single_label_cls_converter

Kind: Module

##### voc_converter

Kind: Module

##### yolo_converter

Kind: Module

##### datadreamer.utils.BaseConverter(abc.ABC)

Kind: Class

Abstract base class for converter.

###### __init__(self, seed = 42)

Kind: Method

###### convert(self, dataset_dir: str, output_dir: str, split_ratios: List [ float ], keep_unlabeled_images: bool = False,
copy_files: bool = True)

Kind: Method

Converts a dataset into another format.

Args:
dataset_dir (str): The directory where the source dataset is located.
output_dir (str): The directory where the processed dataset should be saved.
split_ratios (list of float): The ratios to split the data into training, validation, and test sets.
keep_unlabeled_images (bool, optional): Whether to keep images with no annotations. Defaults to False.
copy_files (bool, optional): Whether to copy the source files to the output directory, otherwise move them. Defaults to True.

No return value.

###### read_annotations(annotation_path: str) -> Dict: Dict

Kind: Static Method

Reads annotations from a JSON file located at the specified path.

Args:
annotation_path (str): The path to the JSON file containing annotations.

Returns:
dict: A dictionary containing the data loaded from the JSON file.

###### make_splits(images: List [ str ], split_ratios: List [ float ], shuffle: bool = True) -> Tuple[List, List, List]:
Tuple[List, List, List]

Kind: Static Method

Splits the list of images into training, validation, and test sets.

Args:
images (list of str): A list of image paths.
split_ratios (list of float): The ratios to split the data into training, validation, and test sets.
shuffle (bool, optional): Whether to shuffle the list of images. Defaults to True.

Returns:
list of str: A list of image paths for the training set.
list of str: A list of image paths for the validation set.
list of str: A list of image paths for the test set.

##### datadreamer.utils.COCOConverter(datadreamer.utils.BaseConverter)

Kind: Class

Class for converting a dataset to COCO format.

Format:

dataset_dir
├── train
│ ├── data
│ │ ├── 0.jpg
│ │ ├── 1.jpg
│ ├── labels.json
├── validation
│ ├── data
│ ├── labels.json
├── test
│ ├── data
│ ├── labels.json

###### __init__(self, seed = 42, is_instance_segmentation: bool = False)

Kind: Method

###### is_instance_segmentation

Kind: Instance Variable

###### convert(self, dataset_dir: str, output_dir: str, split_ratios: List [ float ], keep_unlabeled_images: bool = False,
copy_files: bool = True)

Kind: Method

Converts a dataset into a COCO format.

Args:
dataset_dir (str): The directory where the source dataset is located.
output_dir (str): The directory where the processed dataset should be saved.
split_ratios (list of float): The ratios to split the data into training, validation, and test sets.
keep_unlabeled_images (bool, optional): Whether to keep images with no annotations. Defaults to False.
copy_files (bool, optional): Whether to copy the source files to the output directory, otherwise move them. Defaults to True.

No return value.

###### process_data(self, data: Dict, image_dir: str, output_dir: str, split_ratios: List [ float ], keep_unlabeled_images: bool =
False, copy_files: bool = True)

Kind: Method

Processes the data by dividing it into training and validation sets, and
saves the images and labels in COCO format.

Args:
data (dict): The dictionary containing image annotations.
image_dir (str): The directory where the source images are located.
output_dir (str): The base directory where the processed data will be saved.
split_ratios (list of float): The ratios to split the data into training, validation, and test sets.
keep_unlabeled_images (bool, optional): Whether to keep images with no annotations. Defaults to False.
copy_files (bool, optional): Whether to copy the source files to the output directory, otherwise move them. Defaults to True.

No return value.

###### save_labels(self, dataset_output_dir: str, images_info: List [ Dict ], annotations: List [ Dict ], class_names: List [ str
])

Kind: Method

Saves the labels to a JSON file.

Args:
dataset_output_dir (str): The directory where the labels should be saved.
images_info (list of dict): A list of dictionaries containing image information.
annotations (list of dict): A list of dictionaries containing annotation information.
class_names (list of str): A list of class names.

No return value.

##### datadreamer.utils.Config(luxonis_ml.utils.LuxonisConfig)

Kind: Class

###### save_dir: str

Kind: Class Variable

###### class_names: List[str]

Kind: Class Variable

###### prompts_number: int

Kind: Class Variable

###### task: Literal['detection', 'classification', 'instance-segmentation']

Kind: Class Variable

###### seed: int

Kind: Class Variable

###### device: Literal['cuda', 'cpu']

Kind: Class Variable

###### annotate_only: bool

Kind: Class Variable

###### dataset_format: Literal['raw', 'yolo', 'coco', 'voc', 'luxonis-dataset', 'cls-single']

Kind: Class Variable

###### split_ratios: Annotated[List[float], Field(default=[0.8, 0.1, 0.1], min_length=3, max_length=3)]

Kind: Class Variable

###### prompt_generator: Literal['simple', 'lm', 'tiny', 'qwen2']

Kind: Class Variable

###### synonym_generator: Literal['none', 'llm', 'wordnet']

Kind: Class Variable

###### num_objects_range: Annotated[List[int], Field(default=[1, 3], min_length=2, max_length=2)]

Kind: Class Variable

###### lm_quantization: Literal['none', '4bit']

Kind: Class Variable

###### batch_size_prompt: int

Kind: Class Variable

###### image_generator: Literal['sdxl', 'sdxl-turbo', 'sdxl-lightning', 'shuttle-3']

Kind: Class Variable

###### prompt_prefix: str

Kind: Class Variable

###### prompt_suffix: str

Kind: Class Variable

###### negative_prompt: str

Kind: Class Variable

###### batch_size_image: int

Kind: Class Variable

###### raw_mask_format: Literal['polyline', 'rle']

Kind: Class Variable

###### vis_anns: bool

Kind: Class Variable

###### use_image_tester: bool

Kind: Class Variable

###### image_tester_patience: int

Kind: Class Variable

###### disable_lm_filter: bool

Kind: Class Variable

###### disable_profanity_filter: bool

Kind: Class Variable

###### image_annotator: Literal['owlv2', 'aimv2', 'clip', 'owlv2-slimsam', 'owlv2-sam2']

Kind: Class Variable

###### conf_threshold: float

Kind: Class Variable

###### annotation_iou_threshold: float

Kind: Class Variable

###### use_tta: bool

Kind: Class Variable

###### annotator_size: Literal['base', 'large']

Kind: Class Variable

###### batch_size_annotation: int

Kind: Class Variable

###### dataset_plugin: str

Kind: Class Variable

###### loader_plugin: str

Kind: Class Variable

###### dataset_name: str

Kind: Class Variable

###### dataset_id: str

Kind: Class Variable

###### keep_unlabeled_images: bool

Kind: Class Variable

##### datadreamer.utils.LuxonisDatasetConverter(datadreamer.utils.BaseConverter)

Kind: Class

Class for converting a dataset to LuxonisDataset format.

###### __init__(self, dataset_plugin: str = None, dataset_name: str = None, seed: int = 42, is_instance_segmentation: bool =
False)

Kind: Method

###### is_instance_segmentation

Kind: Instance Variable

###### dataset_plugin

Kind: Instance Variable

###### dataset_name

Kind: Instance Variable

###### convert(self, dataset_dir: str, output_dir: str, split_ratios: List [ float ], keep_unlabeled_images: bool = False,
copy_files: bool = True)

Kind: Method

Converts a dataset into a LuxonisDataset format.

Args:
dataset_dir (str): The directory where the source dataset is located.
output_dir (str): The directory where the processed dataset should be saved.
split_ratios (list of float): The ratios to split the data into training, validation, and test sets.
keep_unlabeled_images (bool, optional): Whether to keep images with no annotations. Defaults to False.
copy_files (bool, optional): Whether to copy the source files to the output directory, otherwise move them. Defaults to True.

No return value.

###### process_data(self, data: Dict, dataset_dir: str, output_dir: str, split_ratios: List [ float ], keep_unlabeled_images: bool
= False)

Kind: Method

Processes the data into LuxonisDataset format.

Args:
data (dict): The data to process.
dataset_dir (str): The directory where the source dataset is located.
output_dir (str): The directory where the processed dataset should be saved.
split_ratios (list of float): The ratios to split the data into training, validation, and test sets.

No return value.

##### datadreamer.utils.SingleLabelClsConverter(datadreamer.utils.BaseConverter)

Kind: Class

Class for converting a dataset for single-label classification task.

NOTE: The number of images after conversion may be different from the number of images in the original dataset, as images with
zero or more than one labels are removed.

Format:

dataset_dir
├── train
│ ├── class_1
│ │ ├── image1.jpg
│ │ ├── image2.jpg
│ ├── class_2
│ │ ├── image3.jpg
│ │ ├── image4.jpg
├── val
│ ├── class_1
│ ├── class_2
├── test
│ ├── class_1
│ ├── class_2

###### __init__(self, seed: int = 42)

Kind: Method

###### convert(self, dataset_dir: str, output_dir: str, split_ratios: List [ float ], keep_unlabeled_images: bool = False,
copy_files: bool = True)

Kind: Method

Converts a dataset into a format suitable for single-label classification.

Args:
dataset_dir (str): The directory where the source dataset is located.
output_dir (str): The directory where the processed dataset should be saved.
split_ratios (list of float): The ratios to split the data into training, validation, and test sets.
keep_unlabeled_images (bool, optional): Whether to keep images with no annotations. Defaults to False.
copy_files (bool, optional): Whether to copy the source files to the output directory, otherwise move them. Defaults to True.

No return value.

###### process_data(self, data: Dict, image_dir: str, output_dir: str, split_ratios: List [ float ], copy_files: bool = True)

Kind: Method

Processes the data by removing images with multiple labels, then dividing it
into training and validation sets, and saves the images with single labels.

Args:
data (dict): The dictionary containing image annotations.
image_dir (str): The directory where the source images are located.
output_dir (str): The base directory where the processed data will be saved.
split_ratios (float): The ratio to split the data into training, validation, and test sets.
copy_files (bool, optional): Whether to copy the source files to the output directory, otherwise move them. Defaults to True.

No return value.

##### datadreamer.utils.VOCConverter(datadreamer.utils.BaseConverter)

Kind: Class

Class for converting a dataset to PASCAL VOC format.

Format:

dataset_dir
├── Annotations/ # XML files with image annotations (bounding boxes, labels, segmentation)
| ├── 0.xml
| ├── 1.xml
| ├── ...
├── ImageSets/
│ ├── Main/ # Main image splits (train, val, test, etc.)
│ ├── train.txt
│ ├── val.txt
│ ├── test.txt
├── JPEGImages/ # Images in JPG format
| ├── 0.jpg
| ├── 1.jpg
| ├── ...
├── SegmentationClass/ # Segmentation masks (with class labels)
| ├── 0.png
| ├── 1.png
| ├── ...
├── SegmentationObject/ # Segmentation masks (object-wise masks)labels.json
| ├── 0.png
| ├── 1.png
| ├── ...

###### __init__(self, seed = 42, is_instance_segmentation: bool = False)

Kind: Method

###### is_instance_segmentation

Kind: Instance Variable

###### convert(self, dataset_dir: str, output_dir: str, split_ratios: List [ float ], keep_unlabeled_images: bool = False,
copy_files: bool = True)

Kind: Method

Convert a dataset to PASCAL VOC format.

Args:
dataset_dir (str): The directory where the source dataset is located.
output_dir (str): The directory where the processed dataset should be saved.
split_ratios (list of float): The ratios to split the data into training, validation, and test sets.
keep_unlabeled_images (bool, optional): Whether to keep images with no annotations. Defaults to False.
copy_files (bool, optional): Whether to copy the source files to the output directory, otherwise move them. Defaults to True.

No return value.

###### process_data(self, data: Dict, image_dir: str, output_dir: str, split_ratios: List [ float ], keep_unlabeled_images: bool =
False, copy_files: bool = True)

Kind: Method

Process the data, create XML annotations and handle dataset splitting.

Args:
data (dict): The dictionary containing image annotations.
image_dir (str): The directory where the source images are located.
output_dir (str): The directory where the processed dataset should be saved.
split_ratios (list of float): The ratios to split the data into training, validation, and test sets.
keep_unlabeled_images (bool, optional): Whether to keep images with no annotations. Defaults to False.
copy_files (bool, optional): Whether to copy the source files to the output directory, otherwise move them. Defaults to True.

No return value.

###### create_image_sets(self, image_sets_dir: str, train_images: List [ str ], val_images: List [ str ], test_images: List [ str
])

Kind: Method

Create text files for each split (train, val, test).

Args:
image_sets_dir (str): The directory where the image sets will be saved.
train_images (list of str): The list of image names for the training set.
val_images (list of str): The list of image names for the validation set.
test_images (list of str): The list of image names for the test set.

No return value.

###### create_xml(self, annotation: Dict, folder_name: str, image_name: str, width: int, height: int, class_names: List [ str ])
-> Element: Element

Kind: Method

Generate XML annotation for a single image.

Args:
annotation (dict): The dictionary containing image annotations.
folder_name (str): The name of the folder where the image is located.
image_name (str): The name of the image file.
width (int): The width of the image.
height (int): The height of the image.
class_names (list of str): The list of class names.

Returns:
Element: The root element of the XML annotation.

###### create_segmentation_masks(self, annotation: Dict, image_name: str, width: int, height: int) -> Tuple[np.ndarray,
np.ndarray]: Tuple[np.ndarray, np.ndarray]

Kind: Method

Create and save segmentation masks (class and object).

Args:
annotation (dict): The dictionary containing image annotations.
image_name (str): The name of the image file.
width (int): The width of the image.
height (int): The height of the image.

Returns:
tuple of np.ndarray: A tuple containing the class mask and object mask.

##### datadreamer.utils.YOLOConverter(datadreamer.utils.BaseConverter)

Kind: Class

Class for converting a dataset to YOLO format.

Format:

dataset_dir
├── train
│ ├── images
│ │ ├── 0.jpg
│ │ ├── 1.jpg
│ ├── labels
│ │ ├── 0.txt
│ │ ├── 1.txt
├── val
│ ├── images
│ ├── labels
├── test
│ ├── images
│ ├── labels

###### __init__(self, seed = 42, is_instance_segmentation: bool = False)

Kind: Method

###### is_instance_segmentation

Kind: Instance Variable

###### convert(self, dataset_dir: str, output_dir: str, split_ratios: List [ float ], keep_unlabeled_images: bool = False,
copy_files: bool = True)

Kind: Method

Converts a dataset into a format suitable for training with YOLO, including
creating training and validation splits.

Args:
dataset_dir (str): The directory where the source dataset is located.
output_dir (str): The directory where the processed dataset should be saved.
split_ratios (list of float): The ratios to split the data into training, validation, and test sets.
keep_unlabeled_images (bool, optional): Whether to keep images with no annotations. Defaults to False.
copy_files (bool, optional): Whether to copy the source files to the output directory, otherwise move them. Defaults to True.

No return value.

###### convert_to_yolo_format(self, box: List [ float ], image_width: int, image_height: int) -> List[float]: List[float]

Kind: Method

Converts bounding box coordinates to YOLO format.

Args:
box (list of float): A list containing the bounding box coordinates [x_min, y_min, x_max, y_max].
image_width (int): The width of the image.
image_height (int): The height of the image.

Returns:
list of float: A list containing the bounding box in YOLO format [x_center, y_center, width, height].

###### convert_masks_to_yolo_format(self, masks: List [ List [ float ] ] | Dict, w: int, h: int) -> List[float]: List[float]

Kind: Method

Converts masks to YOLO format.

Args:
masks (list of list of float): A list containing the masks.
w (int): The width of the image.
h (int): The height of the image.

Returns:
list of float: A list containing the masks in YOLO format.

###### process_data(self, data: Dict, image_dir: str, output_dir: str, split_ratios: List [ float ], keep_unlabeled_images: bool =
False, copy_files: bool = True)

Kind: Method

Processes the data by dividing it into training and validation sets, and
saves the images and labels in YOLO format.

Args:
data (dict): The dictionary containing image annotations.
image_dir (str): The directory where the source images are located.
output_dir (str): The base directory where the processed data will be saved.
split_ratios (float): The ratio to split the data into training, validation, and test sets.
keep_unlabeled_images (bool, optional): Whether to keep images with no annotations. Defaults to False.
copy_files (bool, optional): Whether to copy the source files to the output directory, otherwise move them. Defaults to True.

No return value.

###### create_data_yaml(self, root_dir: str, class_names: List [ str ])

Kind: Method

Creates a YAML file for dataset configuration, specifying paths and class
names.

Args:
root_dir (str): The root directory where the dataset is located.
class_names (list of str): A list of class names.

No return value.

#### __version__: str

Kind: Variable
