is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_timm, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY, PipelineTestCaseMeta if is_vision_available(): from PIL import Image else: class Image: @staticmethod def open(*args, **kwargs): pass def hashimage(image: Image) -> str: m = hashlib.md5(image.tobytes()) return m.hexdigest() @require_vision
def default_feature_extractor(self): return DetrFeatureExtractor.from_pretrained( "facebook/detr-resnet-50") if is_vision_available() else None
def default_feature_extractor(self): return MaskFormerFeatureExtractor.from_pretrained( self.model_checkpoints) if is_vision_available() else None
def default_processor(self): return ViltProcessor.from_pretrained( "dandelin/vilt-b32-finetuned-vqa") if is_vision_available( ) else None