File size: 1,007 Bytes
3e43b52
 
 
 
 
8a011f8
 
3e43b52
 
8a011f8
3e43b52
8a011f8
3e43b52
 
 
8a011f8
 
 
3e43b52
8a011f8
3e43b52
 
 
8a011f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3e43b52
 
 
8a011f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
---
license: mit
tags:
- image-captioning
- clip
- gpt2
- vision-language
---

# CLIP Prefix Caption Model - COCO

This model generates captions for images using CLIP image embeddings and GPT-2 language model.

## Model Details

- **Model Type**: CLIP Prefix Caption
- **Dataset**: COCO
- **Prefix Length**: 10
- **CLIP Model**: ViT-B/32
- **Language Model**: GPT-2

## Usage

```python
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)
```

## Citation

If you use this model, please cite the original CLIP Prefix Caption paper.