Downloads · 30 days
16
22% of all-time downloads
DexterCodeDev/moda-fashion-distilled-512d-vision-only
moda-fashion-distilled-512d-vision-only is a image feature extraction model from DexterCodeDev. Use it for the image feature extraction task on the model card, and read the license before you ship it in a product. It is set up for open_clip. The card lists the license as mit.
A lightweight vision-only checkpoint derived from HopitAI/moda-fashion-distilled-512d, packaged for fashion image-to-image retrieval, product matching, and visual similarity search.
Downloads · 30 days
16
22% of all-time downloads
All-time downloads
73
Public
Parameters
93.3M
373 MB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors373 MB · 100%
From the Hugging Face model README
A lightweight vision-only checkpoint derived from HopitAI/moda-fashion-distilled-512d, packaged for fashion image-to-image retrieval, product matching, and visual similarity search.
This repository removes checkpoint parameters that are not required for image-only inference while retaining the complete visual encoder and the learned MODA 768 → 512 projection.
The retained checkpoint remains in FP32 and is distributed in Safetensors format.
The model converts a fashion image into a 512-dimensional L2-normalized embedding suitable for cosine-similarity search and vector databases.
Input Image
↓
ViT-B/16 SigLIP Visual Encoder
↓
768-D Visual Feature
↓
MODA Linear Projection
768 → 512
↓
L2 Normalization
↓
512-D Fashion Embedding
This vision-only checkpoint contains:
visual.* tensorsproj.weight tensorproj.weight shape: [512, 768]The checkpoint does not include the text-side weights required for text encoding.
This model is designed for:
Because the text encoder weights are not included, this checkpoint does not support:
This repository is specifically intended for image-to-image applications.
| Property | Value |
|---|---|
| Base model | HopitAI/moda-fashion-distilled-512d |
| Vision backbone | ViT-B/16 SigLIP |
| Input resolution | 224 × 224 |
| Visual feature dimension | 768 |
| Final projection | Linear 768 → 512 |
| Projection bias | No |
| Final embedding dimension | 512 |
| Output normalization | L2 |
| Weight precision | FP32 |
| Checkpoint format | Safetensors |
| Text encoder weights | Not included |
| Primary use | Fashion image retrieval |
Install the required packages:
pip install torch open_clip_torch safetensors pillow huggingface_hub
import torch
import torch.nn as nn
import torch.nn.functional as F
import open_clip
from PIL import Image
from huggingface_hub import hf_hub_download
from safetensors.torch import load_file
REPO_ID = "DexterCodeDev/moda-fashion-distilled-512d-vision-only"
# Download checkpoint
model_path = hf_hub_download(
repo_id=REPO_ID,
filename="model.safetensors"
)
# Build the matching OpenCLIP architecture
model, _, preprocess = open_clip.create_model_and_transforms(
"ViT-B-16-SigLIP",
pretrained=None
)
# Load the vision-only MODA checkpoint
state = load_file(model_path)
# Extract the learned MODA 768 -> 512 projection
proj_weight = state.pop("proj.weight")
# Text-side weights are intentionally absent, so strict=False is required
missing, unexpected = model.load_state_dict(
state,
strict=False
)
# Restore the MODA projection
proj = nn.Linear(
768,
512,
bias=False
)
with torch.no_grad():
proj.weight.copy_(proj_weight)
model.eval()
proj.eval()
# Load an image
image = Image.open("fashion_item.jpg").convert("RGB")
image_tensor = preprocess(image).unsqueeze(0)
# Generate normalized 512-D embedding
with torch.no_grad():
visual_features = model.encode_image(image_tensor)
embedding = proj(visual_features)
embedding = F.normalize(
embedding,
p=2,
dim=-1
)
print("Embedding shape:", embedding.shape)
print("Embedding norm:", embedding.norm(dim=-1))
# Expected:
# torch.Size([1, 512])
Use CUDA automatically when available:
device = "cuda" if torch.cuda.is_available() else "cpu"
model = model.to(device)
proj = proj.to(device)
image_tensor = image_tensor.to(device)
with torch.no_grad():
features = model.encode_image(image_tensor)
embedding = F.normalize(
proj(features),
p=2,
dim=-1
)
def encode_image(image_path):
image = Image.open(image_path).convert("RGB")
tensor = preprocess(image).unsqueeze(0).to(device)
with torch.no_grad():
features = model.encode_image(tensor)
embedding = proj(features)
embedding = F.normalize(
embedding,
p=2,
dim=-1
)
return embedding
Example:
embedding = encode_image("shoe.jpg")
print(embedding.shape)
Expected output:
torch.Size([1, 512])
Because the embeddings are L2-normalized, cosine similarity can be calculated using a dot product:
embedding_a = encode_image("shoe_1.jpg")
embedding_b = encode_image("shoe_2.jpg")
similarity = embedding_a @ embedding_b.T
print("Similarity:", similarity.item())
A larger score generally indicates greater similarity in the learned fashion embedding space.
For larger catalogs, process multiple images together:
from PIL import Image
import torch
import torch.nn.functional as F
paths = [
"item1.jpg",
"item2.jpg",
"item3.jpg",
]
batch = torch.stack([
preprocess(Image.open(path).convert("RGB"))
for path in paths
]).to(device)
with torch.no_grad():
features = model.encode_image(batch)
embeddings = F.normalize(
proj(features),
p=2,
dim=-1
)
print(embeddings.shape)
# torch.Size([3, 512])
Each image produces one 512-dimensional normalized vector.
These embeddings can be stored in vector-search systems such as:
A typical production search pipeline is:
Catalog Images
↓
MODA Vision-Only
↓
512-D Embeddings
↓
Vector Database
↑
512-D Query Embedding
↑
Customer Query Image
At search time:
For pure image-to-image retrieval, the text encoder is not required.
This repository retains:
visual.*
proj.weight
The resulting image-only pipeline is:
Image
↓
ViT-B/16 SigLIP
↓
768-D
↓
MODA Projection
↓
512-D
↓
L2 Normalization
This checkpoint intentionally does not contain a complete OpenCLIP multimodal state dictionary.
Do not use:
model.load_state_dict(state, strict=True)
because the text-side weights are intentionally absent.
Use:
model.load_state_dict(state, strict=False)
Missing text-side keys are expected for this vision-only checkpoint.
For best compatibility, use the preprocessing returned by:
open_clip.create_model_and_transforms(
"ViT-B-16-SigLIP",
pretrained=None
)
Avoid changing preprocessing unless you intentionally want different model behavior.
Important preprocessing properties include:
Different preprocessing can produce different embeddings and may affect retrieval quality.
Always apply L2 normalization after the MODA projection:
embedding = F.normalize(
proj(features),
p=2,
dim=-1
)
This produces unit-length embeddings suitable for cosine similarity.
Python:
from huggingface_hub import hf_hub_download
model_path = hf_hub_download(
repo_id="DexterCodeDev/moda-fashion-distilled-512d-vision-only",
filename="model.safetensors"
)
print(model_path)
Hugging Face CLI:
hf download DexterCodeDev/moda-fashion-distilled-512d-vision-only model.safetensors
For production deployments, download and initialize the model once when the application starts.
A typical deployment architecture is:
Application Startup
↓
Download model.safetensors
↓
Load SigLIP visual model
↓
Load MODA projection
↓
Move model to CPU/GPU
↓
Keep model in memory
↓
Serve image embedding requests
The model can be integrated into:
This repository is a derived packaging of:
HopitAI/moda-fashion-distilled-512d
The trained visual representations and learned projection originate from the upstream MODA project.
This repository does not claim to have trained the underlying model.
The modification is limited to packaging the checkpoint for vision-only image retrieval.
visual.*
proj.weight
This checkpoint contains:
162 visual tensors
+
1 projection tensor
=
163 tensors total
The projection tensor has shape:
[512, 768]
Parameters not required by the image-only embedding path are not included.
No FP16 conversion or quantization was applied.
This repository is intended to preserve the visual embedding pathway of the upstream MODA checkpoint.
No independent retrieval benchmark is currently reported for this derivative repository.
For benchmark results and evaluation methodology, refer to the original model:
HopitAI/moda-fashion-distilled-512d
Users should evaluate retrieval performance on their own catalog and query distribution before production use.
Performance may be lower for:
Retrieval quality can also be affected by:
The main checkpoint is:
model.safetensors
It contains the visual-side model parameters and learned MODA 512-D projection.
The checkpoint is distributed using the Safetensors format.
Safetensors stores tensor data without relying on Python pickle execution.
This repository uses the MIT License, following the upstream model repository.
Users should also review the upstream model and project documentation before production or commercial use.
Original model:
HopitAI/moda-fashion-distilled-512d
Hugging Face:
https://huggingface.co/HopitAI/moda-fashion-distilled-512d
MODA project:
https://github.com/hopit-ai/Moda
If you use this checkpoint, please credit the original MODA / HopitAI authors.
Thanks to the MODA and HopitAI authors for releasing the original fashion retrieval model.
This repository provides a smaller vision-only packaging of the upstream trained visual model for image-to-image retrieval and deployment.