| from typing import List, Union | |
| from sglang.srt.models.clip import CLIPModel | |
| from sglang.srt.multimodal.processors.base_processor import ( | |
| BaseMultimodalProcessor, | |
| MultimodalSpecialTokens, | |
| ) | |
| class ClipImageProcessor(BaseMultimodalProcessor): | |
| models = [CLIPModel] | |
| def __init__(self, hf_config, server_args, _processor, *args, **kwargs): | |
| super().__init__(hf_config, server_args, _processor, *args, **kwargs) | |
| self.mm_tokens = MultimodalSpecialTokens(image_token="<image>").build( | |
| _processor | |
| ) | |
| async def process_mm_data_async( | |
| self, image_data: List[Union[str, bytes]], input_text, *args, **kwargs | |
| ): | |
| base_output = self.load_mm_data( | |
| prompt=input_text, | |
| multimodal_tokens=self.mm_tokens, | |
| image_data=image_data, | |
| ) | |
| mm_items, input_ids, _ = self.process_and_combine_mm_data( | |
| base_output, self.mm_tokens | |
| ) | |
| return { | |
| "input_ids": input_ids.tolist(), | |
| "mm_items": mm_items, | |
| } | |
Xet Storage Details
- Size:
- 1.06 kB
- Xet hash:
- c7a15f6e8bbeb21f78160bc332b49732b559b896fefc3c0a5374b981520e8dbb
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.