File size: 2,233 Bytes
699427b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
license: apache-2.0
base_model: javrtg/AnyCalib
tags:
  - mlx
  - camera-calibration
  - swift
library_name: mlx
pipeline_tag: image-feature-extraction
---

# AnyCalib — MLX weights

Converted weights for [mlx-swift-AnyCalib](https://github.com/mnmly/mlx-swift-AnyCalib), a Swift/MLX port of
[AnyCalib](https://github.com/javrtg/AnyCalib) (Tirado-Garín & Civera, ICCV 2025):
single-view camera calibration with a camera model chosen after the network runs.

These are **not** new weights. They are the official AnyCalib checkpoints in a
different container.

## What was changed

* Repacked from PyTorch `.pt` into `safetensors`.
* Convolution tensors transposed `(out, in, kH, kW) → (out, kH, kW, in)` for MLX's
  native NHWC layout. That same rule also reshapes the `(1, 3, 1, 1)` ImageNet
  mean/std buffers to `(1, 1, 1, 3)`.
* Optionally cast to `float16`; the default build is `float32`.

No weight *values* are altered beyond that optional cast. The port is verified
stage by stage against the PyTorch reference — on MLX's CPU backend every stage
matches to within float32's own noise floor (ray field within 0.0003°).

## Layout

One subdirectory per pretrained variant, each holding `config.json` and
`weights.safetensors`:

```
anycalib_dist/
anycalib_edit/
anycalib_gen/
anycalib_pinhole/
```

The variants differ only in training imagery: `pinhole` (perspective only),
`gen` (perspective + distorted), `dist` (distorted + strongly distorted),
`edit` (stretched and cropped perspective).

## Usage

```bash
anycalib calibrate photo.jpg --cam pinhole --repo mnmly/anycalib-mlx
```

The Swift loader resolves these through the shared Hugging Face cache, so a copy
pulled by `huggingface_hub` is reused and vice versa.

## License and attribution

Apache 2.0, inherited from upstream. See `LICENSE` and `NOTICE` in this repo.

Original work © Javier Tirado-Garín and Javier Civera, I3A, University of
Zaragoza. The backbone is DINOv2, © Meta Platforms, Inc., also Apache 2.0.

```bibtex
@InProceedings{tirado2025anycalib,
  author={Javier Tirado-Gar{\'i}n and Javier Civera},
  title={{AnyCalib: On-Manifold Learning for Model-Agnostic Single-View Camera Calibration}},
  booktitle={ICCV},
  year={2025}
}
```