How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("zero-shot-image-classification", model="FLIP-dataset/FLIP-base-32")
pipe(
    "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png",
    candidate_labels=["animals", "humans", "landscape"],
)
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoProcessor, AutoModelForZeroShotImageClassification

processor = AutoProcessor.from_pretrained("FLIP-dataset/FLIP-base-32")
model = AutoModelForZeroShotImageClassification.from_pretrained("FLIP-dataset/FLIP-base-32", device_map="auto")
Quick Links

CLIP model post-trained on 80M human face images.

Trained with TencentPretrain framework on 8 * A100 GPUs:

python3 pretrain.py --dataset_path faceclip.pt \
    --pretrained_model_path models/clip-b32.bin \
    --output_model_path models/faceclip-b32.bin \
    --config_path models/clip/base-32_config.json \
    --vocab_path vocab.json --merges_path merges.txt --tokenizer clip \
    --world_size 8 --gpu_ranks 0 1 2 3 4 5 6 7 --data_processor clip --accumulation_steps 8 --learning_rate 2e-5 \
    --total_steps 200000 --save_checkpoint_steps 20000 --batch_size 160 --report_steps 500

How to use:

from PIL import Image
import requests

from transformers import CLIPProcessor, CLIPModel

model = CLIPModel.from_pretrained("P01son/FaceCLIP-base-32")
processor = CLIPProcessor.from_pretrained("P01son/FaceCLIP-base-32")

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)

inputs = processor(text=["a photo of a cat", "a photo of a dog"], images=image, return_tensors="pt", padding=True)

outputs = model(**inputs)
logits_per_image = outputs.logits_per_image # this is the image-text similarity score
probs = logits_per_image.softmax(dim=1) # we can take the softmax to get the label probabilities
Downloads last month
13
Safetensors
Model size
0.2B params
Tensor type
I64
ยท
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support