Image Feature Extraction
Transformers
Safetensors
English
gr_lite
fashion
image-retrieval
vision-transformer
dino
custom_code
Instructions to use srpone/gr-lite with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use srpone/gr-lite with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-feature-extraction", model="srpone/gr-lite", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("srpone/gr-lite", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README with AutoModel usage and model card
Browse files
README.md
CHANGED
|
@@ -29,24 +29,86 @@ GR-Lite achieves state-of-the-art performance on [LookBench](https://huggingface
|
|
| 29 |
|
| 30 |
## Quick Start
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
## Feature Extraction (Batch)
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
|
|
|
|
|
|
| 37 |
|
| 38 |
## Image Retrieval
|
| 39 |
|
|
|
|
|
|
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
## Model Outputs
|
| 43 |
|
| 44 |
-
The model returns a :
|
| 45 |
|
| 46 |
| Field | Shape | Description |
|
| 47 |
|-------|-------|-------------|
|
| 48 |
-
|
|
| 49 |
-
|
|
| 50 |
|
| 51 |
## Resources
|
| 52 |
|
|
@@ -57,3 +119,12 @@ The model returns a :
|
|
| 57 |
|
| 58 |
## Citation
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
## Quick Start
|
| 31 |
|
| 32 |
+
```python
|
| 33 |
+
from transformers import AutoModel
|
| 34 |
+
import torch
|
| 35 |
+
from PIL import Image
|
| 36 |
+
from torchvision import transforms
|
| 37 |
+
|
| 38 |
+
# Load model
|
| 39 |
+
model = AutoModel.from_pretrained("srpone/gr-lite", trust_remote_code=True)
|
| 40 |
+
model.eval()
|
| 41 |
+
|
| 42 |
+
# Preprocess
|
| 43 |
+
transform = transforms.Compose([
|
| 44 |
+
transforms.Resize((336, 336)),
|
| 45 |
+
transforms.ToTensor(),
|
| 46 |
+
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
|
| 47 |
+
])
|
| 48 |
+
|
| 49 |
+
image = Image.open("your_image.jpg").convert("RGB")
|
| 50 |
+
pixel_values = transform(image).unsqueeze(0) # [1, 3, 336, 336]
|
| 51 |
+
|
| 52 |
+
# Extract embedding
|
| 53 |
+
with torch.no_grad():
|
| 54 |
+
output = model(pixel_values)
|
| 55 |
+
embedding = output.pooler_output # [1, 1024], L2-normalized
|
| 56 |
+
|
| 57 |
+
print(f"Embedding shape: {embedding.shape}")
|
| 58 |
+
```
|
| 59 |
|
| 60 |
## Feature Extraction (Batch)
|
| 61 |
|
| 62 |
+
```python
|
| 63 |
+
from torch.utils.data import DataLoader, Dataset
|
| 64 |
+
|
| 65 |
+
class ImageDataset(Dataset):
|
| 66 |
+
def __init__(self, image_paths, transform):
|
| 67 |
+
self.image_paths = image_paths
|
| 68 |
+
self.transform = transform
|
| 69 |
+
|
| 70 |
+
def __len__(self):
|
| 71 |
+
return len(self.image_paths)
|
| 72 |
+
|
| 73 |
+
def __getitem__(self, idx):
|
| 74 |
+
image = Image.open(self.image_paths[idx]).convert("RGB")
|
| 75 |
+
return self.transform(image)
|
| 76 |
+
|
| 77 |
+
# Create dataloader
|
| 78 |
+
dataset = ImageDataset(your_image_paths, transform)
|
| 79 |
+
loader = DataLoader(dataset, batch_size=64, num_workers=4)
|
| 80 |
+
|
| 81 |
+
# Extract all embeddings
|
| 82 |
+
all_embeddings = []
|
| 83 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 84 |
+
model.to(device)
|
| 85 |
+
|
| 86 |
+
with torch.no_grad():
|
| 87 |
+
for batch in loader:
|
| 88 |
+
output = model(batch.to(device))
|
| 89 |
+
all_embeddings.append(output.pooler_output.cpu())
|
| 90 |
|
| 91 |
+
embeddings = torch.cat(all_embeddings, dim=0) # [N, 1024]
|
| 92 |
+
```
|
| 93 |
|
| 94 |
## Image Retrieval
|
| 95 |
|
| 96 |
+
```python
|
| 97 |
+
import torch.nn.functional as F
|
| 98 |
|
| 99 |
+
# query_emb: [1, 1024], gallery_embs: [N, 1024]
|
| 100 |
+
similarity = query_emb @ gallery_embs.T # cosine similarity (already L2-normalized)
|
| 101 |
+
top_k_indices = similarity.argsort(descending=True)[0, :10]
|
| 102 |
+
```
|
| 103 |
|
| 104 |
## Model Outputs
|
| 105 |
|
| 106 |
+
The model returns a `BaseModelOutputWithPooling`:
|
| 107 |
|
| 108 |
| Field | Shape | Description |
|
| 109 |
|-------|-------|-------------|
|
| 110 |
+
| `pooler_output` | `[B, 1024]` | L2-normalized CLS token embedding (use this for retrieval) |
|
| 111 |
+
| `last_hidden_state` | `[B, 446, 1024]` | Full sequence output (CLS + 4 registers + 441 patches) |
|
| 112 |
|
| 113 |
## Resources
|
| 114 |
|
|
|
|
| 119 |
|
| 120 |
## Citation
|
| 121 |
|
| 122 |
+
```bibtex
|
| 123 |
+
@article{gao2026lookbench,
|
| 124 |
+
title={LookBench: A Live and Holistic Open Benchmark for Fashion Image Retrieval},
|
| 125 |
+
author={Chao Gao and Siqiao Xue and Yimin Peng and Jiwen Fu and Tingyi Gu and Shanshan Li and Fan Zhou},
|
| 126 |
+
year={2026},
|
| 127 |
+
url={https://arxiv.org/abs/2601.14706},
|
| 128 |
+
journal={arXiv preprint arXiv:2601.14706},
|
| 129 |
+
}
|
| 130 |
+
```
|