File size: 910 Bytes
55a294e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from typing import List
from PIL.Image import Image
from transformers import CLIPImageProcessor
from transformers.image_processing_utils import BaseImageProcessor
from .mm_utils import process_images

# TODO can inherit from CLIPImageProcessor instead and use the process function directly.
class InstellaVLImageProcessor(BaseImageProcessor):
    r"""
    Pre-process images
    """
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    def process(self,
                images: List[Image],
                processor: CLIPImageProcessor,
                model_cfg: dict
    ):
        image_tensors = process_images(images, processor, model_cfg)
        if images is None:
            return {
            "pixel_values": None,
            }
        else:
            return{
                "pixel_values": image_tensors,
            }

InstellaVLImageProcessor.register_for_auto_class()