|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import copy |
|
|
|
|
|
from transformers.configuration_utils import PretrainedConfig |
|
|
from transformers.utils import logging |
|
|
from transformers import LlamaConfig, Qwen2Config, Qwen3Config |
|
|
|
|
|
from .configuration_intern_vit import InternVisionConfig |
|
|
from .configuration_whisper import WhisperConfig |
|
|
from .configuration_voicelm import VoiceLMConfig |
|
|
from .configuration_flow import FlowConfig |
|
|
from .configuration_hifigan import HiFiGanConfig |
|
|
|
|
|
logger = logging.get_logger(__name__) |
|
|
|
|
|
class InteractiveOmniConfig(PretrainedConfig): |
|
|
model_type = 'interactiveomni' |
|
|
is_composition = True |
|
|
|
|
|
def __init__( |
|
|
self, |
|
|
vision_config=None, |
|
|
llm_config=None, |
|
|
audio_config=None, |
|
|
voicelm_config=None, |
|
|
flow_config=None, |
|
|
hifigan_config=None, |
|
|
use_backbone_lora=0, |
|
|
use_llm_lora=0, |
|
|
pad2square=False, |
|
|
select_layer=-4, |
|
|
force_image_size=None, |
|
|
downsample_ratio=0.5, |
|
|
template=None, |
|
|
dynamic_image_size=False, |
|
|
use_thumbnail=False, |
|
|
ps_version='v1', |
|
|
min_dynamic_patch=1, |
|
|
max_dynamic_patch=6, |
|
|
**kwargs): |
|
|
super().__init__(**kwargs) |
|
|
|
|
|
if vision_config is None: |
|
|
vision_config = {} |
|
|
logger.info('vision_config is None. Initializing the InternVisionConfig with default values.') |
|
|
|
|
|
if llm_config is None: |
|
|
llm_config = {} |
|
|
logger.info('llm_config is None. Initializing the Qwen3Config as default values.') |
|
|
|
|
|
if audio_config is None: |
|
|
audio_config = {} |
|
|
logger.info('audio_config is None. Initializing the WhisperConfig as default values.') |
|
|
|
|
|
if voicelm_config is None: |
|
|
voicelm_config = {} |
|
|
logger.info('voicelm_config is None. Initializing the VoiceLMConfig as default values') |
|
|
|
|
|
if flow_config is None: |
|
|
flow_config = {} |
|
|
logger.info('flow_config is None. Initializing the FlowConfig as default values') |
|
|
|
|
|
if hifigan_config is None: |
|
|
hifigan_config = {} |
|
|
logger.info('hifigan_config is None. Initializing the HiFiGanConfig as default values') |
|
|
|
|
|
self.vision_config = InternVisionConfig(**vision_config) |
|
|
self.audio_config = WhisperConfig(**audio_config) |
|
|
self.llm_config = Qwen3Config(**llm_config) |
|
|
self.voicelm_config = VoiceLMConfig(**voicelm_config) |
|
|
self.flow_config = FlowConfig(**flow_config) |
|
|
self.hifigan_config = HiFiGanConfig(**hifigan_config) |
|
|
self.use_backbone_lora = use_backbone_lora |
|
|
self.use_llm_lora = use_llm_lora |
|
|
self.pad2square = pad2square |
|
|
self.select_layer = select_layer |
|
|
self.force_image_size = force_image_size |
|
|
self.downsample_ratio = downsample_ratio |
|
|
self.template = template |
|
|
self.dynamic_image_size = dynamic_image_size |
|
|
self.use_thumbnail = use_thumbnail |
|
|
self.ps_version = ps_version |
|
|
self.min_dynamic_patch = min_dynamic_patch |
|
|
self.max_dynamic_patch = max_dynamic_patch |
|
|
|
|
|
logger.info(f'vision_select_layer: {self.select_layer}') |
|
|
logger.info(f'ps_version: {self.ps_version}') |
|
|
logger.info(f'min_dynamic_patch: {self.min_dynamic_patch}') |
|
|
logger.info(f'max_dynamic_patch: {self.max_dynamic_patch}') |
|
|
pass |
|
|
|
|
|
def to_dict(self): |
|
|
""" |
|
|
Serializes this instance to a Python dictionary. Override the default [`~PretrainedConfig.to_dict`]. |
|
|
|
|
|
Returns: |
|
|
`Dict[str, any]`: Dictionary of all the attributes that make up this configuration instance, |
|
|
""" |
|
|
output = copy.deepcopy(self.__dict__) |
|
|
output['vision_config'] = self.vision_config.to_dict() |
|
|
output['audio_config'] = self.audio_config.to_dict() |
|
|
output['llm_config'] = self.llm_config.to_dict() |
|
|
output['voicelm_config'] = self.voicelm_config.to_dict() |
|
|
output['flow_config'] = self.flow_config.to_dict() |
|
|
output['hifigan_config'] = self.hifigan_config.to_dict() |
|
|
output['model_type'] = self.__class__.model_type |
|
|
output['use_backbone_lora'] = self.use_backbone_lora |
|
|
output['use_llm_lora'] = self.use_llm_lora |
|
|
output['pad2square'] = self.pad2square |
|
|
output['select_layer'] = self.select_layer |
|
|
output['force_image_size'] = self.force_image_size |
|
|
output['downsample_ratio'] = self.downsample_ratio |
|
|
output['template'] = self.template |
|
|
output['dynamic_image_size'] = self.dynamic_image_size |
|
|
output['use_thumbnail'] = self.use_thumbnail |
|
|
output['ps_version'] = self.ps_version |
|
|
output['min_dynamic_patch'] = self.min_dynamic_patch |
|
|
output['max_dynamic_patch'] = self.max_dynamic_patch |
|
|
|
|
|
return output |