--- language: - en license: cc-by-sa-4.0 library_name: transformers tags: - image-similarity - image-retrieval - computer-vision - e-commerce - dinov2 - gem-pooling - pytorch - safetensors datasets: - e-commerce-product-images pipeline_tag: feature-extraction base_model: Trendyol/trendyol-dino-v2-ecommerce-256d --- # Trendyol DinoV2.1 Image Similarity Model Fine-tuned DinoV2 (ViT-B/14) with **[GeM pooling](https://arxiv.org/abs/1711.02512)** for e-commerce product image retrieval. This is the successor to [`Trendyol/trendyol-dino-v2-ecommerce-256d`](https://huggingface.co/Trendyol/trendyol-dino-v2-ecommerce-256d). **Paper:** TBD — *"Visual Search at Trendyol"* (in review) ## Model Details - **Model Type**: Image Similarity / Retrieval - **Architecture**: DinoV2 ViT-B/14 + [GeM pooling](https://arxiv.org/abs/1711.02512) + linear projection (ArcFace-trained) - **Embedding Dimension**: 256 - **Input Size**: 224×224 - **Checkpoint**: `ray-dinov2-full_catalog_1000_20-pfc-gem-mlp-run_12` epoch **09** - **Framework**: PyTorch / SafeTensors ## What's new vs v2 | | v2 | **v2.1** | |---|---|---| | Pooling / head | Flatten spatial tokens → Linear(196608→256) | **[GeM](https://arxiv.org/abs/1711.02512)** → Linear(768→256) | | Training data | 300 distinct products per ~3400 categories | 1000 distinct products per ~3400 categories | | Preprocess | Lanczos/JPEG/332 pad pipeline | Scale+pad to 224 (training inference preprocess) | ## Quick Start ```python import torch from PIL import Image from transformers import AutoModel, AutoImageProcessor device = "cuda" if torch.cuda.is_available() else "cpu" repo = "Trendyol/trendyol-dino-v2.1-ecommerce-256d" processor = AutoImageProcessor.from_pretrained(repo, trust_remote_code=True) model = AutoModel.from_pretrained(repo, trust_remote_code=True).to(device).eval() image = Image.open("your_image.jpg").convert("RGB") inputs = processor(images=image, return_tensors="pt") inputs = {k: v.to(device) for k, v in inputs.items()} with torch.no_grad(): embeddings = model(**inputs).last_hidden_state # [1, 256] print(embeddings.shape) ``` ## Preprocessing Pipeline 1. **ScaleImage**: resize so max side = 224 (keep aspect ratio) 2. **PadToSquare**: pad with color 255 3. **Resize**: 224×224 4. **ToTensor** + **ImageNet Normalize** (mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) ## Installation ```bash pip install transformers torch torchvision safetensors pillow numpy ``` ## Intended Use - Product image similarity search - Visual recommendations / duplicate detection - Content-based retrieval in e-commerce ## Limitations - Optimized for product / e-commerce images - Requires `trust_remote_code=True` - Classification heads from training are **not** included in this Hub export (embeddings only) ## License See [LICENSE](LICENSE). Same terms as the v2 release: source-available; commercial use requires attribution and prior notification to Trendyol (`scr.datascience@trendyol.com`). ## Citation ``` @misc{trendyol-dinov2-ecommerce-v21, title={Trendyol DinoV2.1 E-commerce Image Similarity Model}, author={Trendyol Data Science Team}, year={2026}, url={https://huggingface.co/Trendyol/trendyol-dino-v2.1-ecommerce-256d} } @article{radenovic2018gem, title={Fine-tuning CNN Image Retrieval with No Human Annotation}, author={Radenovi{\'c}, Filip and Tolias, Giorgos and Chum, Ond{\v{r}}ej}, journal={IEEE Transactions on Pattern Analysis and Machine Intelligence}, volume={41}, number={7}, pages={1655--1668}, year={2018}, doi={10.1109/TPAMI.2018.2846566}, note={GeM pooling; also arXiv:1711.02512} } @misc{trendyol-visual-search-tbd, title={Visual Search at Trendyol}, author={Trendyol Data Science Team}, year={2026}, note={Paper TBD (in review)} } ```