Downloads · 30 days
0
Hamza66628/clip-prefix-caption-coco
clip-prefix-caption-coco is a machine learning model from Hamza66628. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
This model generates captions for images using CLIP image embeddings and GPT-2 language model.
Downloads · 30 days
0
Access
Public
Updated Dec 5, 2025
Repo size
1.3 GB
Likes
0
Public
Click a slice to open those files.
.pt624 MB · 100%
From the Hugging Face model README
This model generates captions for images using CLIP image embeddings and GPT-2 language model.
from huggingface_hub import hf_hub_download
import torch
from transformers import GPT2Tokenizer, GPT2LMHeadModel
import clip
# Load model
checkpoint_path = hf_hub_download(
repo_id="Hamza66628/clip-prefix-caption-coco",
filename="model.pt"
)
checkpoint = torch.load(checkpoint_path, map_location="cpu")
# Initialize model (use same architecture as training)
model = ClipCaptionModel(prefix_length=10)
model.load_state_dict(checkpoint, strict=False)
model.eval()
# Generate caption
# (See full usage in the notebook)
If you use this model, please cite the original CLIP Prefix Caption paper.