Update README.md
Browse files123---license: cc-by-sa-4.0---123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402---license: cc-by-sa-4.0library_name: pytorchpipeline_tag: image-classificationbase_model: facebook/dinov3-vits16-pretrain-lvd1689mtags:- image-classification- computer-vision- dinov3- pytorch- safetensors- prototype-learning- hard-example-mining- feedback-routing- experimentaldatasets:- pendingmetrics:- accuracy- f1- precision- recall---# DINO-Protomorph**Feedback-Gated Prototype Morphing for Hard-Case Image Classification**ProtoMorph-DINO is an experimental image classification head designed to run on top of a frozen DINOv3 vision backbone.The model explores a custom architecture for hard-case image classification using:- frozen DINOv3 patch embeddings- ProtoMorph prototype-style transformation blocks- layer memory attention- confidence-based hard-case routing- top-2 probability feedback- Delta-RBF hard expert refinement- logit fusion for difficult samplesThis repository currently contains the early project/model-card setup for ProtoMorph-DINO. Training and evaluation results are still pending.This repository does **not** redistribute DINOv3 weights. Users must download DINOv3 separately from its official source and comply with the upstream DINOv3 license.This project is an independent research implementation and is not affiliated with Meta AI, Hugging Face, or the official DINOv3 project.---## Architecture```textImageβFrozen DINOv3βPatch map z0βProtoMorph block 1βLayer Memory AttentionβProtoMorph block 2βLayer Memory AttentionβMain logitsβHard-case gateβββ easy: return main logitsβββ hard:feedback from top-2 probabilitiesmodulate DINO patch maprun Delta-RBF hard expertfuse logits```---## Model SummaryProtoMorph-DINO is built around the idea that not every image needs the same amount of computation.For easy images, the model returns the main classifier output directly.For difficult or ambiguous images, the model activates a feedback branch. This branch uses the top-2 predicted probabilities to modulate the DINO patch map, then sends the modified representation through a specialized Delta-RBF hard expert before fusing the logits.The main research goal is to test whether feedback-guided hard-case refinement can improve classification performance over a standard frozen-backbone linear or MLP head.---## Intended UseThis model is intended for:- image classification research- hard-example routing experiments- prototype learning experiments- frozen-backbone classifier research- fine-grained classification experiments- educational and experimental computer vision projectsThis model is **not** intended for safety-critical use.Do not use this model for medical, legal, financial, biometric, security-critical, or production decisions without proper validation.---## Model FilesRecommended repository layout:```text.βββ README.mdβββ config.jsonβββ labels.txtβββ protomorph_head.safetensorsβββ inference/βββ model.pyβββ infer.py```The main weight file is expected to be:```textprotomorph_head.safetensors```This file contains only the custom ProtoMorph classification head.DINOv3 backbone weights are not included.---## BackboneDefault backbone:```textfacebook/dinov3-vits16-pretrain-lvd1689m```The backbone is used as a frozen visual feature extractor.For RTX 3090-class GPUs, the ViT-S/16 DINOv3 variant is recommended as a practical starting point because it keeps VRAM usage manageable while still producing strong patch embeddings.---## InstallationRecommended environment:```textPython 3.11PyTorch 2.4.0CUDA 12.4 PyTorch wheel```Install PyTorch:```bashpip install torch==2.4.0 torchvision==0.19.0 --index-url https://download.pytorch.org/whl/cu124```Install dependencies:```bashpip install transformers safetensors pillow numpy tqdm accelerate```---## Example Usage```pythonimport torchfrom PIL import Imagefrom transformers import AutoImageProcessor, AutoModelfrom safetensors.torch import load_file# Replace with your local or Hugging Face repo path.REPO_ID = "YOUR_USERNAME/protomorph-dino"# DINOv3 is loaded separately.BACKBONE_NAME = "facebook/dinov3-vits16-pretrain-lvd1689m"device = "cuda" if torch.cuda.is_available() else "cpu"processor = AutoImageProcessor.from_pretrained(BACKBONE_NAME)backbone = AutoModel.from_pretrained(BACKBONE_NAME,torch_dtype=torch.float16 if device == "cuda" else torch.float32,).to(device)backbone.eval()for p in backbone.parameters():p.requires_grad = False# Load your ProtoMorph model class from your local code.# from model import ProtoMorphDINOClassifier## model = ProtoMorphDINOClassifier(...)# state = load_file("protomorph_head.safetensors")# model.load_state_dict(state, strict=True)# model.to(device)# model.eval()image = Image.open("example.jpg").convert("RGB")inputs = processor(images=image, return_tensors="pt").to(device)with torch.no_grad():outputs = backbone(**inputs)tokens = outputs.last_hidden_state# DINOv3 ViT outputs include special tokens before patch tokens.# Your implementation should remove CLS/register tokens according to its config.## logits = model(tokens)# probs = torch.softmax(logits, dim=-1)# print(probs)```For the full runnable inference script, see the associated GitHub repository.---## Config Example```json{"model_name": "ProtoMorph-DINO","backbone_name": "facebook/dinov3-vits16-pretrain-lvd1689m","num_classes": "pending","patch_dim": 384,"hidden_dim": 512,"num_prototypes": 64,"memory_heads": 8,"hard_gate_confidence_threshold": 0.65,"hard_gate_margin_threshold": 0.15,"hard_expert_weight": 0.5,"dtype": "float16"}```---## Training Status**Status: Pending**This repository is being prepared before full training and evaluation. At the moment, final training runs, benchmark comparisons, and validated metrics are not available yet.If this repository contains an untrained or randomly initialized head, predictions are not meaningful yet.---## Dataset**Dataset: Pending**Training dataset information will be added after the dataset selection and training split are finalized.Expected fields to add later:- dataset name- number of classes- train/validation/test split- preprocessing steps- augmentation strategy- label mappingClass labels are expected to be stored in:```textlabels.txt```---## Evaluation**Evaluation results: Pending**The model has not yet been fully trained and evaluated. Metrics will be added after experiments are complete.| Metric | Value ||---|---:|| Accuracy | Pending || F1 | Pending || Precision | Pending || Recall | Pending |Recommended baselines:| Baseline | Why Compare ||---|---|| DINOv3 + Linear Probe | Minimal frozen-backbone baseline || DINOv3 + MLP Head | Strong simple head baseline || CLIP + Linear Probe | Popular vision-language baseline || ConvNeXt | Strong CNN-style baseline || ViT | Standard transformer baseline |---## Planned ExperimentsPlanned research questions:- Can feedback from top-2 probabilities improve hard-case classification?- Can prototype-style transformations improve frozen DINO features?- Does hard-case routing reduce unnecessary compute?- Can a Delta-RBF expert improve class-boundary decisions?- Does memory attention help preserve useful intermediate representations?- Can this approach outperform a normal linear or MLP head on fine-grained datasets?---## LimitationsKnown limitations:- The architecture is experimental.- Training and evaluation results are currently pending.- The hard-case gate requires threshold tuning.- The Delta-RBF hard expert may overfit small datasets.- Inference may be slower for hard samples.- The model should be compared against simple baselines before claiming improvement.- This repo does not include DINOv3 weights.- The custom head may not generalize outside the dataset it was trained on.---## LicenseThe ProtoMorph head weights in this repository are released under:```textCreative Commons Attribution-ShareAlike 4.0 InternationalCC BY-SA 4.0```You may use, share, and adapt these weights, including commercially, provided that you give appropriate credit and distribute adapted versions under CC BY-SA 4.0 or a compatible license.This license applies only to the ProtoMorph head weights and related files released in this repository.It does not apply to:- DINOv3- PyTorch- Hugging Face Transformers- third-party datasets- third-party model weights- upstream dependenciesDINOv3 is not redistributed in this repository. Users are responsible for obtaining DINOv3 separately and complying with its license.---## AttributionIf you use this model or build on it, please credit:```textProtoMorph-DINO: Feedback-Gated Prototype Morphing for Hard-Case Image ClassificationAuthor: YOUR_NAMERepository: https://huggingface.co/YOUR_USERNAME/protomorph-dino```BibTeX:```bibtex@software{protomorph_dino_2026,title = {ProtoMorph-DINO: Feedback-Gated Prototype Morphing for Hard-Case Image Classification},author = {YOUR_NAME},year = {2026},url = {https://huggingface.co/YOUR_USERNAME/protomorph-dino}}```---## DisclaimerThis is a research prototype.The model is provided for experimentation and educational use. It should not be used in production or high-stakes environments without independent validation, dataset auditing, robustness testing, and bias evaluation.---## Project LinksGitHub repository: coming soon```texthttps://github.com/shiowo/DINO-Protomorph```Hugging Face model page:```texthttps://huggingface.co/shiowo/DINO-Protomorph```
README.md+402-3