(
self,
model_path: str,
backend: str,
vision_config: VisionConfig = None,
backend_config: TurbomindEngineConfig | PytorchEngineConfig | None = None,
trust_remote_code: bool = False,
)
| 74 | """Image encoder.""" |
| 75 | |
| 76 | def __init__( |
| 77 | self, |
| 78 | model_path: str, |
| 79 | backend: str, |
| 80 | vision_config: VisionConfig = None, |
| 81 | backend_config: TurbomindEngineConfig | PytorchEngineConfig | None = None, |
| 82 | trust_remote_code: bool = False, |
| 83 | ): |
| 84 | self.model = load_vl_model(model_path, |
| 85 | backend, |
| 86 | backend_config=backend_config, |
| 87 | trust_remote_code=trust_remote_code) |
| 88 | self.mm_feature_dtype = _resolve_mm_feature_dtype( |
| 89 | getattr(self.model, 'hf_config', None), backend_config) |
| 90 | if self.model is not None and hasattr(self.model, 'set_mm_feature_dtype'): |
| 91 | self.model.set_mm_feature_dtype(self.mm_feature_dtype) |
| 92 | if vision_config is None: |
| 93 | vision_config = VisionConfig() |
| 94 | self.vision_config = vision_config |
| 95 | self.max_batch_size = vision_config.max_batch_size |
| 96 | self.executor = ThreadPoolExecutor(max_workers=1) |
| 97 | self._uses_new_preprocess = self._is_new_preprocess_api(self.model) |
| 98 | torch.cuda.empty_cache() |
| 99 | |
| 100 | @staticmethod |
| 101 | def _is_new_preprocess_api(model) -> bool: |
nothing calls this directly
no test coverage detected