Views
No views yet
| Checkpoint | Encoder | Quantization | DA-2K overall acc |
|---|---|---|---|
baseline_student_final.safetensors | ViT-S | none (full precision) | 0.6489 |
student_final.safetensors | ViT-S | 1.58-bit ternary weights ({-1,0,1}) + int8 activations on the DINOv2 encoder linears | 0.6407 |
These are early distillation runs on unlabeled data, not fully trained production models, so both sit below the published DAV2-S DA-2K numbers. The meaningful quantity here is the relative fp ↔ 1.58-bit gap, which is small.
| Scene | Full precision | 1.58-bit | Δ |
|---|---|---|---|
| indoor | 0.6333 | 0.6119 | −0.0214 |
| outdoor | 0.6599 | 0.6453 | −0.0146 |
| non_real | 0.7129 | 0.7030 | −0.0099 |
| transparent_reflective | 0.6028 | 0.5981 | −0.0047 |
| adverse_style | 0.6128 | 0.6067 | −0.0061 |
| aerial | 0.6082 | 0.6289 | +0.0207 |
| underwater | 0.6667 | 0.6752 | +0.0085 |
| object | 0.7230 | 0.7095 | −0.0135 |
| OVERALL | 0.6489 | 0.6407 | −0.0082 |
transformers modelsDepthAnythingV2 state_dicts. They do not load via
AutoModel.from_pretrained. You need the model code from the
Depth-Anything-V2-Bit repo (a fork of
Depth Anything V2).1import torch
2from safetensors.torch import load_file
3from depth_anything_v2.dpt import DepthAnythingV2
4
5cfg = {'encoder': 'vits', 'features': 64, 'out_channels': [48, 96, 192, 384]}
6model = DepthAnythingV2(**cfg)
7model.load_state_dict(load_file('baseline_student_final.safetensors'))
8model.eval()
9
10depth = model.infer_image(bgr_image, input_size=518) # HxW, higher = closerBitLinear before loading, so the ternary
weights land in the right modules:1import torch
2from safetensors.torch import load_file
3from depth_anything_v2.dpt import DepthAnythingV2
4from bitnet import convert_linear_to_bitlinear
5
6cfg = {'encoder': 'vits', 'features': 64, 'out_channels': [48, 96, 192, 384]}
7model = DepthAnythingV2(**cfg)
8convert_linear_to_bitlinear(model.pretrained) # swap DINOv2 nn.Linear -> BitLinear
9model.load_state_dict(load_file('student_final.safetensors'))
10model.eval()
11
12depth = model.infer_image(bgr_image, input_size=518)student_1p58bit.safetensors stores ternary weights as fp32 masters, so it is the same size as
the full-precision file. This is the form needed for the fake-quant / fold-inference paths above.
To realize the ~8× weight reduction, bit-pack the encoder (4 ternary weights per byte) with the
helper in the repo:1from bitnet import pack_model_for_storage
2pack_model_for_storage(model.pretrained) # -> packed_weight (uint8) + w_scale
3torch.save(model.state_dict(), 'student_packed.pth') # ~8x smaller encoder weights
4# load back with: prepare_packed_load(...) + load + unpack_model_from_storage(...)nn.Linear weights (BitNet b1.58: absmean ternarization, per-token int8 activations, STE).1@article{depth_anything_v2,
2 title={Depth Anything V2},
3 author={Yang, Lihe and Kang, Bingyi and Huang, Zilong and Zhao, Zhen and Xu, Xiaogang and Feng, Jiashi and Zhao, Hengshuang},
4 journal={arXiv:2406.09414},
5 year={2024}
6}