[VLM] Various cleanup and fixes (#14806)
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
This commit is contained in:
@@ -433,6 +433,10 @@ class MultiModalFieldConfig:
|
||||
:func:`MultiModalFieldConfig.flat`
|
||||
"""
|
||||
|
||||
if size_per_item.ndim != 1:
|
||||
raise ValueError("size_per_item should be a 1-D tensor, "
|
||||
f"but found shape: {size_per_item.shape}")
|
||||
|
||||
slice_idxs = [0, *accumulate(size_per_item)]
|
||||
slices = [
|
||||
slice(slice_idxs[i], slice_idxs[i + 1])
|
||||
|
||||
@@ -176,6 +176,10 @@ class AudioProcessorItems(ProcessorBatchItems[HfAudioItem]):
|
||||
def __init__(self, data: Sequence[HfAudioItem]) -> None:
|
||||
super().__init__(data, "audio")
|
||||
|
||||
def get_audio_length(self, item_idx: int) -> int:
|
||||
audio = self.get(item_idx)
|
||||
return len(audio)
|
||||
|
||||
|
||||
class AudioEmbeddingItems(EmbeddingItems):
|
||||
|
||||
|
||||
@@ -1311,8 +1311,8 @@ class BaseMultiModalProcessor(ABC, Generic[_I]):
|
||||
|
||||
def _bind_and_group_updates(
|
||||
self,
|
||||
prompt_updates: list[PromptUpdate],
|
||||
) -> dict[str, list[BoundPromptUpdate]]:
|
||||
prompt_updates: Sequence[PromptUpdate],
|
||||
) -> dict[str, Sequence[BoundPromptUpdate]]:
|
||||
tokenizer = self.info.get_tokenizer()
|
||||
|
||||
it = (update.bind(tokenizer) for update in prompt_updates)
|
||||
|
||||
Reference in New Issue
Block a user