Skip to content

Commit

Permalink
Iterate
Browse files Browse the repository at this point in the history
Signed-off-by: DarkLight1337 <[email protected]>
  • Loading branch information
DarkLight1337 committed Dec 30, 2024
1 parent 5384037 commit 7752760
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 6 additions & 5 deletions vllm/multimodal/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,21 +323,22 @@ def _parse_video_data(

return VideoProcessorInput(data_items)

def _get_mm_data_parsers(self) -> Mapping[str, ModalityDataParser]:
def _get_subparsers(self) -> Mapping[str, ModalityDataParser]:
return {
"audio": self._parse_audio_data,
"image": self._parse_image_data,
"video": self._parse_video_data,
}

def parse_mm_data(self,mm_data: MultiModalDataDict) -> MultiModalDataItems:
parsers = self._get_mm_data_parsers()
def parse_mm_data(self,
mm_data: MultiModalDataDict) -> MultiModalDataItems:
subparsers = self._get_subparsers()

mm_items = MultiModalDataItems()
for k, v in mm_data.items():
if k not in parsers:
if k not in subparsers:
raise ValueError(f"Unsupported modality: {k}")

mm_items[k] = parsers[k](v)
mm_items[k] = subparsers[k](v)

return mm_items
3 changes: 3 additions & 0 deletions vllm/multimodal/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,9 @@ def _get_data_parser(self) -> MultiModalDataParser:
"""
Construct a data parser to preprocess multi-modal data items
before passing them to :meth:`_get_hf_mm_data`.
You can support additional modalities by creating a subclass
of :class:`MultiModalDataParser` that has additional subparsers.
"""
return MultiModalDataParser()

Expand Down

0 comments on commit 7752760

Please sign in to comment.