Loading imgutils/preprocess/transformers/__init__.py +1 −0 Original line number Diff line number Diff line Loading @@ -11,5 +11,6 @@ from .bit import create_bit_transforms, create_transforms_from_bit_processor from .blip import create_blip_transforms, create_transforms_from_blip_processor from .clip import create_clip_transforms, create_transforms_from_clip_processor from .convnext import create_convnext_transforms, create_transforms_from_convnext_processor from .mobilenetv2 import create_mobilenetv2_transforms, create_transforms_from_mobilenetv2_processor from .siglip import create_siglip_transforms, create_transforms_from_siglip_processor from .vit import create_vit_transforms, create_transforms_from_vit_processor imgutils/preprocess/transformers/base.py +0 −27 Original line number Diff line number Diff line Loading @@ -21,10 +21,6 @@ Usage: ) """ from PIL import Image from ..pillow import PillowResize try: import transformers except (ImportError, ModuleNotFoundError): Loading Loading @@ -137,26 +133,3 @@ def create_transforms_from_transformers(processor): pass else: raise NotProcessorTypeError(f'Unknown transformers processor - {processor!r}.') def _create_resize(size, resample=Image.BICUBIC): """ Create a PillowResize transform based on the given size configuration. :param size: Dictionary containing size configuration, either with 'shortest_edge' or both 'height' and 'width' keys :type size: dict :param resample: PIL resampling filter to use for resizing, defaults to Image.BICUBIC :type resample: int :return: A PillowResize transform configured according to the size parameters :rtype: PillowResize :raises ValueError: If the size configuration is not recognized """ if "shortest_edge" in size: return PillowResize(size["shortest_edge"], interpolation=resample) elif "height" in size and "width" in size: return PillowResize((size["height"], size["width"]), interpolation=resample) else: raise ValueError(f'Unknown size configuration - {size!r}.') # pragma: no cover imgutils/preprocess/transformers/bit.py +2 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,8 @@ library integration. from PIL import Image from .base import OPENAI_CLIP_MEAN, OPENAI_CLIP_STD, _DEFAULT, register_creators_for_transformers, _check_transformers, \ NotProcessorTypeError, _create_resize NotProcessorTypeError from .size import _create_resize from ..pillow import PillowConvertRGB, PillowCenterCrop, PillowToTensor, PillowNormalize, PillowCompose, \ PillowRescale Loading imgutils/preprocess/transformers/blip.py +2 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,8 @@ all implemented using Pillow-based operations. from PIL import Image from .base import OPENAI_CLIP_STD, OPENAI_CLIP_MEAN, _DEFAULT, _check_transformers, NotProcessorTypeError, \ register_creators_for_transformers, _create_resize register_creators_for_transformers from .size import _create_resize from ..pillow import PillowConvertRGB, PillowRescale, PillowNormalize, PillowToTensor, PillowCompose _DEFAULT_SIZE = {"height": 384, "width": 384} Loading imgutils/preprocess/transformers/clip.py +2 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,8 @@ The module integrates with the Hugging Face transformers library and provides co from PIL import Image from .base import _check_transformers, NotProcessorTypeError, register_creators_for_transformers, OPENAI_CLIP_MEAN, \ OPENAI_CLIP_STD, _DEFAULT, _create_resize OPENAI_CLIP_STD, _DEFAULT from .size import _create_resize from ..pillow import PillowCenterCrop, PillowToTensor, PillowNormalize, PillowCompose, PillowRescale, \ PillowConvertRGB Loading Loading
imgutils/preprocess/transformers/__init__.py +1 −0 Original line number Diff line number Diff line Loading @@ -11,5 +11,6 @@ from .bit import create_bit_transforms, create_transforms_from_bit_processor from .blip import create_blip_transforms, create_transforms_from_blip_processor from .clip import create_clip_transforms, create_transforms_from_clip_processor from .convnext import create_convnext_transforms, create_transforms_from_convnext_processor from .mobilenetv2 import create_mobilenetv2_transforms, create_transforms_from_mobilenetv2_processor from .siglip import create_siglip_transforms, create_transforms_from_siglip_processor from .vit import create_vit_transforms, create_transforms_from_vit_processor
imgutils/preprocess/transformers/base.py +0 −27 Original line number Diff line number Diff line Loading @@ -21,10 +21,6 @@ Usage: ) """ from PIL import Image from ..pillow import PillowResize try: import transformers except (ImportError, ModuleNotFoundError): Loading Loading @@ -137,26 +133,3 @@ def create_transforms_from_transformers(processor): pass else: raise NotProcessorTypeError(f'Unknown transformers processor - {processor!r}.') def _create_resize(size, resample=Image.BICUBIC): """ Create a PillowResize transform based on the given size configuration. :param size: Dictionary containing size configuration, either with 'shortest_edge' or both 'height' and 'width' keys :type size: dict :param resample: PIL resampling filter to use for resizing, defaults to Image.BICUBIC :type resample: int :return: A PillowResize transform configured according to the size parameters :rtype: PillowResize :raises ValueError: If the size configuration is not recognized """ if "shortest_edge" in size: return PillowResize(size["shortest_edge"], interpolation=resample) elif "height" in size and "width" in size: return PillowResize((size["height"], size["width"]), interpolation=resample) else: raise ValueError(f'Unknown size configuration - {size!r}.') # pragma: no cover
imgutils/preprocess/transformers/bit.py +2 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,8 @@ library integration. from PIL import Image from .base import OPENAI_CLIP_MEAN, OPENAI_CLIP_STD, _DEFAULT, register_creators_for_transformers, _check_transformers, \ NotProcessorTypeError, _create_resize NotProcessorTypeError from .size import _create_resize from ..pillow import PillowConvertRGB, PillowCenterCrop, PillowToTensor, PillowNormalize, PillowCompose, \ PillowRescale Loading
imgutils/preprocess/transformers/blip.py +2 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,8 @@ all implemented using Pillow-based operations. from PIL import Image from .base import OPENAI_CLIP_STD, OPENAI_CLIP_MEAN, _DEFAULT, _check_transformers, NotProcessorTypeError, \ register_creators_for_transformers, _create_resize register_creators_for_transformers from .size import _create_resize from ..pillow import PillowConvertRGB, PillowRescale, PillowNormalize, PillowToTensor, PillowCompose _DEFAULT_SIZE = {"height": 384, "width": 384} Loading
imgutils/preprocess/transformers/clip.py +2 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,8 @@ The module integrates with the Hugging Face transformers library and provides co from PIL import Image from .base import _check_transformers, NotProcessorTypeError, register_creators_for_transformers, OPENAI_CLIP_MEAN, \ OPENAI_CLIP_STD, _DEFAULT, _create_resize OPENAI_CLIP_STD, _DEFAULT from .size import _create_resize from ..pillow import PillowCenterCrop, PillowToTensor, PillowNormalize, PillowCompose, PillowRescale, \ PillowConvertRGB Loading