Builder
Modules concerning the builder utilities of GLLM Multimodal modules.
build_modality_converter(source_modality, target_modality, task_type=ModalityConverterTask.AUTO, approach_type=None, preset=None, **kwargs)
Build and initialize a modality converter instance for a given configuration.
The factory looks up the converter class based on the combination of
- source_modality: input modality (e.g., Modality.IMAGE, Modality.AUDIO)
- target_modality: output modality (e.g., Modality.TEXT)
- task_type: conversion task (e.g., CAPTIONING, TRANSCRIPT, MERMAID, or AUTO)
- approach_type: the converter's algorithmic approach; required for non-AUTO tasks, must be None for AUTO
All supported combinations must be registered in MODALITY_CONVERTER_REGISTRY.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_modality |
Modality
|
The source modality. |
required |
target_modality |
Modality
|
The output modality. |
required |
task_type |
ModalityConverterTask
|
The conversion task. Defaults to ModalityConverterTask.AUTO. |
AUTO
|
approach_type |
ModalityConverterApproach | None
|
The approach for the conversion. Required for non-AUTO tasks; must be None for task_type=AUTO. |
None
|
preset |
str | None
|
Preset identifier for the converter's .from_preset() method. If None, uses the default preset for the class. |
None
|
**kwargs |
Additional keyword arguments passed to .from_preset(). |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
BaseModalityConverter |
BaseModalityConverter
|
An instance of the matching converter class. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the configuration is invalid or not registered, including: - (source_modality, target_modality, task_type, approach) not registered - approach_type missing for non-AUTO task_type - approach_type provided when task_type is AUTO - Any dimension unsupported for the given combination |
Modules
modality_converter_builder
Defines a convenience function to build a modality converter.
References
NONE
build_modality_converter(source_modality, target_modality, task_type=ModalityConverterTask.AUTO, approach_type=None, preset=None, **kwargs)
Build and initialize a modality converter instance for a given configuration.
The factory looks up the converter class based on the combination of
- source_modality: input modality (e.g., Modality.IMAGE, Modality.AUDIO)
- target_modality: output modality (e.g., Modality.TEXT)
- task_type: conversion task (e.g., CAPTIONING, TRANSCRIPT, MERMAID, or AUTO)
- approach_type: the converter's algorithmic approach; required for non-AUTO tasks, must be None for AUTO
All supported combinations must be registered in MODALITY_CONVERTER_REGISTRY.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_modality |
Modality
|
The source modality. |
required |
target_modality |
Modality
|
The output modality. |
required |
task_type |
ModalityConverterTask
|
The conversion task. Defaults to ModalityConverterTask.AUTO. |
AUTO
|
approach_type |
ModalityConverterApproach | None
|
The approach for the conversion. Required for non-AUTO tasks; must be None for task_type=AUTO. |
None
|
preset |
str | None
|
Preset identifier for the converter's .from_preset() method. If None, uses the default preset for the class. |
None
|
**kwargs |
Additional keyword arguments passed to .from_preset(). |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
BaseModalityConverter |
BaseModalityConverter
|
An instance of the matching converter class. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the configuration is invalid or not registered, including: - (source_modality, target_modality, task_type, approach) not registered - approach_type missing for non-AUTO task_type - approach_type provided when task_type is AUTO - Any dimension unsupported for the given combination |