Downloads · 30 days
21
3% of all-time downloads
mlx-community/clip-vit-base-patch16
clip-vit-base-patch16 is a machine learning model from mlx-community. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for mlx. The card lists the license as apache-2.0.
This model was converted to MLX format from clip-vit-base-patch16. Refer to the original model card for more details on the model.
Downloads · 30 days
21
3% of all-time downloads
All-time downloads
659
Public
Repo size
599 MB
Likes
2
Public
Click a slice to open those files.
.npz599 MB · 100%
From the Hugging Face model README
This model was converted to MLX format from clip-vit-base-patch16.
Refer to the original model card for more details on the model.
Download the repository 👇
pip install huggingface_hub hf_transfer
export HF_HUB_ENABLE_HF_TRANSFER=1
huggingface-cli download --local-dir <LOCAL FOLDER PATH> mlx-community/clip-vit-base-patch16
Install mlx-examples.
git clone git@github.com:ml-explore/mlx-examples.git
cd clip
pip install -r requirements.txt
Run the model.
from PIL import Image
import clip
model, tokenizer, img_processor = clip.load("mlx_model")
inputs = {
"input_ids": tokenizer(["a photo of a cat", "a photo of a dog"]),
"pixel_values": img_processor(
[Image.open("assets/cat.jpeg"), Image.open("assets/dog.jpeg")]
),
}
output = model(**inputs)
# Get text and image embeddings:
text_embeds = output.text_embeds
image_embeds = output.image_embeds