Instructions to use AL-GR/Forge-EMB-mmclip with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AL-GR/Forge-EMB-mmclip with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="AL-GR/Forge-EMB-mmclip")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("AL-GR/Forge-EMB-mmclip", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download utils/vision_transform.py from AL-GR/Forge-EMB-mmclip: direct link, hf CLI and curl.
- Browser
- Download file 775 Bytes
-
https://huggingface.co/AL-GR/Forge-EMB-mmclip/resolve/main/utils/vision_transform.py
- Command line
-
hf download hf://AL-GR/Forge-EMB-mmclip/utils/vision_transform.py
-
curl -L -o vision_transform.py https://huggingface.co/AL-GR/Forge-EMB-mmclip/resolve/main/utils/vision_transform.py
775 Bytes
| import torchvision.transforms as transforms | |
| class CLIPTransform(object): | |
| def __init__(self, mode='train'): | |
| normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], | |
| std=[0.229, 0.224, 0.225]) | |
| if mode == 'train': | |
| self.transforms = transforms.Compose([ | |
| transforms.RandomResizedCrop(224, scale=(0.5, 1.0)), | |
| transforms.ToTensor(), | |
| normalize | |
| ]) | |
| else: | |
| self.transforms = transforms.Compose([ | |
| transforms.Resize(224), | |
| transforms.CenterCrop(224), | |
| transforms.ToTensor(), | |
| normalize | |
| ]) | |
| def __call__(self, image): | |
| return self.transforms(image) |