# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/ml.clip.ipynb.

# %% auto 0
__all__ = ['load_clip_preprocess', 'make_tfms_from_clip_preprocess']

# %% ../../nbs/ml.clip.ipynb 3
from torchvision import transforms
from .vision import TorchVisionTransform

# %% ../../nbs/ml.clip.ipynb 4
def load_clip_preprocess(clip_model_name):
    from clip import clip
    return clip.load(clip_model_name, device='cpu')[1]


# %% ../../nbs/ml.clip.ipynb 5
def make_tfms_from_clip_preprocess(clip_preprocess):
    item_tfms = TorchVisionTransform(transforms.Compose(clip_preprocess.transforms[:-1]))
    batch_tfms = TorchVisionTransform(transforms.Compose(clip_preprocess.transforms[-1:]))
    return item_tfms, batch_tfms
