[Bugfix] Fix MiniCPMV Image input inference failed (#22813)
Signed-off-by: HWH <67449739+jio-H@users.noreply.github.com> Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk> Signed-off-by: Cyrus Leung <cyrus.tl.leung@gmail.com> Co-authored-by: DarkLight1337 <tlleungac@connect.ust.hk> Co-authored-by: Cyrus Leung <cyrus.tl.leung@gmail.com>
This commit is contained in:
co-authored by
DarkLight1337
Cyrus Leung
parent
da2705198f
commit
9bd9294f0e
@@ -85,6 +85,23 @@ class MiniCPMVImagePixelInputs(TensorSchema):
|
||||
- w: Width
|
||||
"""
|
||||
|
||||
def _validate_nested_tensors(
|
||||
self,
|
||||
value: Union[list[torch.Tensor], tuple[torch.Tensor, ...]],
|
||||
field_name: str,
|
||||
expected_shape: tuple[Union[int, str], ...],
|
||||
dynamic_dims: set[str],
|
||||
) -> tuple[int, ...]:
|
||||
# value[0] is the scaled image,
|
||||
# and value[1:] is a collection of image slices.
|
||||
# It is ensured that all slices in the collection
|
||||
# have the same shape.
|
||||
if field_name == "pixel_values":
|
||||
value = value[1:] if len(value) > 1 else value
|
||||
|
||||
return super()._validate_nested_tensors(value, field_name,
|
||||
expected_shape, dynamic_dims)
|
||||
|
||||
type: Literal["pixel_values"] = "pixel_values"
|
||||
|
||||
# Note that the image size may vary, so we pass it as a list instead of a
|
||||
|
||||
Reference in New Issue
Block a user