File size: 2,153 Bytes
f1298e6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
from transformers import PretrainedConfig
from typing import List
import json
# from transformers import CONFIG_MAPPING
from peft import PeftConfig
from .configuration_vision import Idefics2VisionConfig
from .configuration_internlm2 import InternLM2Config
from .configuration_projector import ProjectorConfig
from .configuration_connector import Idefics2ConnectorConfig
from .image_processor import Idefics2ImageProcessor
from .configuration_downsampler import DownsamplerConfig
class WeMMConfig(PretrainedConfig):
model_type = "wemm_hf"
def __init__(
self,
vision_config = None,
text_config = None,
projector_config = None,
connector_config = None,
adapter_path = None,
image_processor = None,
do_image_splitting = False,
spliter_emb_config = None,
downsampler_config = None,
tokenizer_config = None,
**kwargs
):
# vision_config
if vision_config is not None:
self.vision_config = Idefics2VisionConfig(**vision_config)
# text_config
if text_config is not None:
self.text_config = InternLM2Config(**text_config)
# projector_config
if projector_config is not None:
self.projector_config = ProjectorConfig(**projector_config)
# connector_config
if connector_config is not None:
self.connector_config = Idefics2ConnectorConfig(**connector_config)
if image_processor is not None:
self.image_processor = image_processor
if adapter_path is not None:
self.adapter_path = adapter_path
self.do_image_splitting = do_image_splitting
if spliter_emb_config is not None:
self.spliter_emb_config = spliter_emb_config
if downsampler_config is not None:
self.downsampler_config = DownsamplerConfig(**downsampler_config)
if tokenizer_config is not None:
self.tokenizer_config = tokenizer_config
super().__init__(**kwargs)
|