File size: 4,667 Bytes
6eb07ba c9e5647 6eb07ba a15fec5 7bc81ce a15fec5 7bc81ce a15fec5 15d437f 7bc81ce 15d437f 7bc81ce 15d437f 7bc81ce a15fec5 3ab6d8c a15fec5 |
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
---
language:
- en
license: cc-by-sa-4.0
library_name: transformers
tags:
- image-similarity
- image-retrieval
- computer-vision
- e-commerce
- dinov2
- pytorch
- safetensors
datasets:
- e-commerce-product-images
metrics:
- cosine-similarity
- euclidean-distance
pipeline_tag: feature-extraction
model-index:
- name: Trendyol DinoV2 E-commerce Image Similarity
results:
- task:
type: image-similarity
dataset:
type: e-commerce-product-images
name: Product Image Similarity
metrics:
- type: cosine_similarity
value: 0.89
name: Cosine Similarity Score
---
# Trendyol DinoV2 Image Similarity Model
This repository contains a fine-tuned DinoV2 model for image similarity and retrieval tasks, specifically trained on e-commerce product images.
## Model Details
- **Model Type**: Image Similarity/Retrieval
- **Architecture**: DinoV2 ViT-B/14 with ArcFace loss
- **Embedding Dimension**: 256
- **Input Size**: 224x224
- **Framework**: PyTorch
- **Format**: SafeTensors
## Usage
### Quick Start
```python
import torch
from PIL import Image
from transformers import AutoModel, AutoImageProcessor
device = 'cuda'
# Load model and processor from Hugging Face Hub
processor = AutoImageProcessor.from_pretrained("Trendyol/trendyol-dino-v2-ecommerce-256d", trust_remote_code=True)
model = AutoModel.from_pretrained("Trendyol/trendyol-dino-v2-ecommerce-256d", trust_remote_code=True)
model.to(device)
# Load and process an image
image = Image.open('your_image.jpg').convert('RGB')
inputs = processor(images=image, return_tensors="pt")
# Move inputs to CUDA
inputs = {k: v.to(device) for k, v in inputs.items()}
# Get embeddings
with torch.no_grad():
outputs = model(**inputs)
embeddings = outputs.last_hidden_state # Shape: [1, 256]
print("Generated dimensional embedding shape:", embeddings.shape[1])
```
### Preprocessing Pipeline
The model uses a specific preprocessing pipeline that's crucial for good performance:
1. **DownScale (Lanczos)**: Resize to max dimension of 332px
2. **JPEG Compression**: Apply quality=90 compression
3. **Scale Image**: Scale to max dimension of 332px
4. **Pad to Square**: Pad with color value 255
5. **Resize**: Resize to 224x224
6. **ToTensor**: Convert to PyTorch tensor
7. **Normalize**: ImageNet normalization (mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
## Installation
Install the required dependencies:
```bash
pip install transformers torch torchvision safetensors pillow numpy opencv-python
```
## Model Architecture
The model consists of:
- **Backbone**: DinoV2 ViT-B/14 (frozen during training)
- **Projection Head**: Linear layer mapping to 256 dimensions
- **Normalization**: L2 normalization for similarity computation
## Training Details
- **Loss Function**: ArcFace loss for metric learning
- **Training Data**: E-commerce product images
- **Epoch**: 9
- **PyTorch Version**: 2.8.0
## Intended Use
This model is designed for:
- Product image similarity search
- Visual product recommendations
- Duplicate product detection
- Content-based image retrieval in e-commerce
## Limitations
- Optimized specifically for product/e-commerce images
- May not generalize well to other image domains
- Requires specific preprocessing pipeline for optimal performance
- Requires transformers library for feature extractor functionality
## License
This model is released by Trendyol as a source-available, non-open-source model. See the [LICENSE file](https://huggingface.co/Trendyol/trendyol-dino-v2-ecommerce-256d/blob/main/LICENSE) for full details.
You are allowed to:
- View, download, and evaluate the model weights.
- Use the model for non-commercial research and internal testing.
- Use the model or its derivatives for commercial purposes, provided that:
- You cite Trendyol as the original model creator.
- You notify Trendyol in advance via [email protected] or other designated contact.
You are not allowed to:
- Redistribute or host the model or its derivatives on third-party platforms without prior written consent from Trendyol.
- Use the model in applications violating ethical standards, including but not limited to surveillance, misinformation, or harm to individuals or groups.
By downloading or using this model, you agree to the terms above.
© 2025 Trendyol Group. All rights reserved.
## Citation
```
@misc{trendyol-dinov2-ecommerce,
title={Trendyol DinoV2 E-commerce Image Similarity Model},
author={Trendyol Data Science Team},
year={2025},
url={https://huggingface.co/Trendyol/trendyol-dino-v2-ecommerce-256d}
}
```
|