2023-05-10 01:18:02 +02:00
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
from extensions.multimodal.abstract_pipeline import AbstractMultimodalPipeline
|
|
|
|
|
2023-10-10 23:40:52 +02:00
|
|
|
available_pipelines = ['llava-7b', 'llava-13b', 'llava-llama-2-13b']
|
2023-05-10 01:18:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
def get_pipeline(name: str, params: dict) -> Optional[AbstractMultimodalPipeline]:
|
|
|
|
if name == 'llava-7b':
|
|
|
|
from .llava import LLaVA_v0_7B_Pipeline
|
|
|
|
return LLaVA_v0_7B_Pipeline(params)
|
|
|
|
if name == 'llava-13b':
|
|
|
|
from .llava import LLaVA_v0_13B_Pipeline
|
|
|
|
return LLaVA_v0_13B_Pipeline(params)
|
2023-10-10 23:40:52 +02:00
|
|
|
if name == 'llava-llama-2-13b':
|
|
|
|
from .llava import LLaVA_LLaMA_2_13B_Pipeline
|
|
|
|
return LLaVA_LLaMA_2_13B_Pipeline(params)
|
2023-05-10 01:18:02 +02:00
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
def get_pipeline_from_model_name(model_name: str, params: dict) -> Optional[AbstractMultimodalPipeline]:
|
|
|
|
if 'llava' not in model_name.lower():
|
|
|
|
return None
|
2023-10-10 23:40:52 +02:00
|
|
|
if 'llama-2' in model_name.lower():
|
|
|
|
if '13b' in model_name.lower():
|
|
|
|
from .llava import LLaVA_LLaMA_2_13B_Pipeline
|
|
|
|
return LLaVA_LLaMA_2_13B_Pipeline(params)
|
2023-05-10 01:18:02 +02:00
|
|
|
if '7b' in model_name.lower():
|
|
|
|
from .llava import LLaVA_v0_7B_Pipeline
|
|
|
|
return LLaVA_v0_7B_Pipeline(params)
|
|
|
|
if '13b' in model_name.lower():
|
|
|
|
from .llava import LLaVA_v0_13B_Pipeline
|
|
|
|
return LLaVA_v0_13B_Pipeline(params)
|
|
|
|
return None
|