fix(critical/BREAKING): correct config, regenerate weights, add ONNX v1.1, requires transformers >= 5.4.0

#5
by LPX55 - opened
Borderless R&D org
edited 1 day ago

Summary

This PR fixes the model after discovering the safetensors weights, config, and preprocessor were all incorrect. The model had been serving 500K+ monthly downloads with silently wrong inference results.

Root cause

The original HF port was hastily created for an internal proof-of-concept. The model.safetensors was converted from different weights than the training checkpoint. The config.json had ViT-Base values (12 heads, intermediate_size=3072) instead of ViT-Small (6 heads, intermediate_size=1536). The preprocessor squashed non-square images.

What changed

Critical fixes

  • model.safetensors — regenerated from the authoritative training checkpoint pretrained_weights/model_v11_ViT_384_base_ckpt.pt
  • config.jsonnum_classes 2→1, num_attention_heads 12→6, intermediate_size 3072→1536, removed redundant fields
  • preprocessor_config.jsonshortest_edge: 440 + do_center_crop (preserves aspect ratio)

ONNX v1.1

  • 5 new variants exported from corrected weights (84 MB FP32 down to 16 MB Q4)
  • Previous 8 variants archived in onnx_legacy/

Documentation

  • README.md — rewritten with fix notice, breaking change warning, ONNX variant guide, v2 teaser
  • CHANGELOG.md — detailed change log of every commit
  • AGENTS.md — created for LLM-based coding agents

Housekeeping

  • LICENSE added with original MIT copyright + Borderless contributions
  • modeling_vit_classifier.py moved to scripts/ and deprecated
  • model_legacy.safetensors + model_fixed.safetensors archived

Breaking change

  • transformers >= 5.4.0 now required — older versions lack shortest_edge resize and will crash

Verification

Corrected model output matches the original timm training pipeline within 0.004%.

Full changelog

See CHANGELOG.md for the complete commit-by-commit breakdown.

LPX55 changed pull request title from chore: fix inference widget to fix(critical): correct config, regenerate weights, add ONNX v1.1, full docs overhaul
Borderless R&D org
edited 1 day ago

[reserved]

LPX55 changed pull request title from fix(critical): correct config, regenerate weights, add ONNX v1.1, full docs overhaul to fix(critical/BREAKING): correct config, regenerate weights, add ONNX v1.1, requires transformers >= 5.4.0
LPX55 pinned discussion
Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment