neuralftw 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. neuralftw-0.1.0/LICENSE +21 -0
  2. neuralftw-0.1.0/PKG-INFO +324 -0
  3. neuralftw-0.1.0/README.md +268 -0
  4. neuralftw-0.1.0/pyproject.toml +147 -0
  5. neuralftw-0.1.0/pyproject.toml.orig +152 -0
  6. neuralftw-0.1.0/src/neuralftw/__init__.py +12 -0
  7. neuralftw-0.1.0/src/neuralftw/__init__.pyi +40 -0
  8. neuralftw-0.1.0/src/neuralftw/_errors.py +28 -0
  9. neuralftw-0.1.0/src/neuralftw/_types.py +12 -0
  10. neuralftw-0.1.0/src/neuralftw/_utils.py +103 -0
  11. neuralftw-0.1.0/src/neuralftw/analysis/__init__.py +36 -0
  12. neuralftw-0.1.0/src/neuralftw/analysis/intrinsic_dim.py +347 -0
  13. neuralftw-0.1.0/src/neuralftw/analysis/variogram.py +469 -0
  14. neuralftw-0.1.0/src/neuralftw/cli.py +434 -0
  15. neuralftw-0.1.0/src/neuralftw/conf/model/aef.yaml +6 -0
  16. neuralftw-0.1.0/src/neuralftw/conf/model/climplicit.yaml +5 -0
  17. neuralftw-0.1.0/src/neuralftw/conf/model/csp-fmow.yaml +5 -0
  18. neuralftw-0.1.0/src/neuralftw/conf/model/csp-inat.yaml +5 -0
  19. neuralftw-0.1.0/src/neuralftw/conf/model/gair.yaml +5 -0
  20. neuralftw-0.1.0/src/neuralftw/conf/model/geoclip.yaml +5 -0
  21. neuralftw-0.1.0/src/neuralftw/conf/model/geoclosp.yaml +5 -0
  22. neuralftw-0.1.0/src/neuralftw/conf/model/gtloc.yaml +5 -0
  23. neuralftw-0.1.0/src/neuralftw/conf/model/hydroloc.yaml +5 -0
  24. neuralftw-0.1.0/src/neuralftw/conf/model/le-sinr.yaml +5 -0
  25. neuralftw-0.1.0/src/neuralftw/conf/model/mind-3072.yaml +7 -0
  26. neuralftw-0.1.0/src/neuralftw/conf/model/mind-head.yaml +6 -0
  27. neuralftw-0.1.0/src/neuralftw/conf/model/mind.yaml +7 -0
  28. neuralftw-0.1.0/src/neuralftw/conf/model/nerf.yaml +5 -0
  29. neuralftw-0.1.0/src/neuralftw/conf/model/osmgraphclip-a-l10.yaml +5 -0
  30. neuralftw-0.1.0/src/neuralftw/conf/model/osmgraphclip-a-l40.yaml +5 -0
  31. neuralftw-0.1.0/src/neuralftw/conf/model/osmgraphclip-ms-l10.yaml +5 -0
  32. neuralftw-0.1.0/src/neuralftw/conf/model/osmgraphclip.yaml +5 -0
  33. neuralftw-0.1.0/src/neuralftw/conf/model/rff3072.yaml +8 -0
  34. neuralftw-0.1.0/src/neuralftw/conf/model/satclip-resnet18-l10.yaml +5 -0
  35. neuralftw-0.1.0/src/neuralftw/conf/model/satclip-resnet18-l40.yaml +5 -0
  36. neuralftw-0.1.0/src/neuralftw/conf/model/satclip-resnet50-l10.yaml +5 -0
  37. neuralftw-0.1.0/src/neuralftw/conf/model/satclip-resnet50-l40.yaml +5 -0
  38. neuralftw-0.1.0/src/neuralftw/conf/model/satclip-vit16-l10.yaml +5 -0
  39. neuralftw-0.1.0/src/neuralftw/conf/model/satclip.yaml +5 -0
  40. neuralftw-0.1.0/src/neuralftw/conf/model/sh40.yaml +5 -0
  41. neuralftw-0.1.0/src/neuralftw/conf/model/sincos.yaml +4 -0
  42. neuralftw-0.1.0/src/neuralftw/conf/model/sinr.yaml +5 -0
  43. neuralftw-0.1.0/src/neuralftw/conf/model/sled-s2.yaml +5 -0
  44. neuralftw-0.1.0/src/neuralftw/conf/model/sled.yaml +5 -0
  45. neuralftw-0.1.0/src/neuralftw/conf/model/spherical-harmonics.yaml +5 -0
  46. neuralftw-0.1.0/src/neuralftw/conf/model/taxabind.yaml +5 -0
  47. neuralftw-0.1.0/src/neuralftw/conf/model/terranova-st.yaml +6 -0
  48. neuralftw-0.1.0/src/neuralftw/conf/model/terranova.yaml +6 -0
  49. neuralftw-0.1.0/src/neuralftw/conf/model/tessera.yaml +6 -0
  50. neuralftw-0.1.0/src/neuralftw/conf/model/tte.yaml +5 -0
  51. neuralftw-0.1.0/src/neuralftw/conf/model/xyz.yaml +4 -0
  52. neuralftw-0.1.0/src/neuralftw/coordbench/__init__.py +10 -0
  53. neuralftw-0.1.0/src/neuralftw/coordbench/__init__.pyi +93 -0
  54. neuralftw-0.1.0/src/neuralftw/coordbench/catalog.py +161 -0
  55. neuralftw-0.1.0/src/neuralftw/coordbench/config.py +575 -0
  56. neuralftw-0.1.0/src/neuralftw/coordbench/datasets.py +850 -0
  57. neuralftw-0.1.0/src/neuralftw/coordbench/leaderboard.py +132 -0
  58. neuralftw-0.1.0/src/neuralftw/coordbench/run.py +1181 -0
  59. neuralftw-0.1.0/src/neuralftw/coordbench/taxonomy.py +119 -0
  60. neuralftw-0.1.0/src/neuralftw/data/cities15000.parquet +0 -0
  61. neuralftw-0.1.0/src/neuralftw/models/__init__.py +10 -0
  62. neuralftw-0.1.0/src/neuralftw/models/__init__.pyi +244 -0
  63. neuralftw-0.1.0/src/neuralftw/models/_base.py +275 -0
  64. neuralftw-0.1.0/src/neuralftw/models/_utils.py +177 -0
  65. neuralftw-0.1.0/src/neuralftw/models/climplicit.py +503 -0
  66. neuralftw-0.1.0/src/neuralftw/models/csp.py +466 -0
  67. neuralftw-0.1.0/src/neuralftw/models/encoders.py +358 -0
  68. neuralftw-0.1.0/src/neuralftw/models/geoclosp.py +220 -0
  69. neuralftw-0.1.0/src/neuralftw/models/gtloc.py +181 -0
  70. neuralftw-0.1.0/src/neuralftw/models/hydroloc.py +221 -0
  71. neuralftw-0.1.0/src/neuralftw/models/lesinr.py +176 -0
  72. neuralftw-0.1.0/src/neuralftw/models/mind.py +429 -0
  73. neuralftw-0.1.0/src/neuralftw/models/onnx.py +472 -0
  74. neuralftw-0.1.0/src/neuralftw/models/osmgraphclip.py +218 -0
  75. neuralftw-0.1.0/src/neuralftw/models/products.py +673 -0
  76. neuralftw-0.1.0/src/neuralftw/models/registry.py +417 -0
  77. neuralftw-0.1.0/src/neuralftw/models/rff_capsule.py +543 -0
  78. neuralftw-0.1.0/src/neuralftw/models/satclip.py +598 -0
  79. neuralftw-0.1.0/src/neuralftw/models/sinr.py +223 -0
  80. neuralftw-0.1.0/src/neuralftw/models/terranova.py +1016 -0
  81. neuralftw-0.1.0/src/neuralftw/models/tte.py +432 -0
  82. neuralftw-0.1.0/src/neuralftw/probes/__init__.py +71 -0
  83. neuralftw-0.1.0/src/neuralftw/probes/classifiers.py +505 -0
  84. neuralftw-0.1.0/src/neuralftw/probes/linear.py +888 -0
  85. neuralftw-0.1.0/src/neuralftw/probes/metrics.py +173 -0
  86. neuralftw-0.1.0/src/neuralftw/probes/spatial.py +457 -0
  87. neuralftw-0.1.0/src/neuralftw/probes/splits.py +261 -0
  88. neuralftw-0.1.0/src/neuralftw/py.typed +0 -0
  89. neuralftw-0.1.0/src/neuralftw/viz.py +312 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Taylor Geospatial
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,324 @@
1
+ Metadata-Version: 2.4
2
+ Name: neuralftw
3
+ Version: 0.1.0
4
+ Summary: Implicit Neural Representations for Earth Observation.
5
+ Keywords: coordbench,earth-observation,geospatial,implicit-neural-representations,location-encoder,pytorch,remote-sensing
6
+ Author: Isaac Corley, Taylor Geospatial
7
+ Author-email: Isaac Corley <isaac.a.corley@gmail.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Classifier: Topic :: Scientific/Engineering :: GIS
18
+ Classifier: Typing :: Typed
19
+ Requires-Dist: filelock>=3.13
20
+ Requires-Dist: huggingface-hub>=0.23
21
+ Requires-Dist: lazy-loader>=0.4
22
+ Requires-Dist: matplotlib>=3.8
23
+ Requires-Dist: numpy>=2.1
24
+ Requires-Dist: onnxruntime>=1.18
25
+ Requires-Dist: pandas>=2.2
26
+ Requires-Dist: pyarrow>=18
27
+ Requires-Dist: pyyaml>=6
28
+ Requires-Dist: safetensors>=0.4
29
+ Requires-Dist: scikit-learn>=1.5
30
+ Requires-Dist: scipy>=1.14
31
+ Requires-Dist: torch>=2.5
32
+ Requires-Dist: torchid>=0.6.0
33
+ Requires-Dist: neuralftw[products,style,tests] ; extra == 'all'
34
+ Requires-Dist: numcodecs>=0.13 ; extra == 'products'
35
+ Requires-Dist: pyproj>=3.6 ; extra == 'products'
36
+ Requires-Dist: requests>=2.31 ; extra == 'products'
37
+ Requires-Dist: s3fs>=2024 ; extra == 'products'
38
+ Requires-Dist: zarr>=3 ; extra == 'products'
39
+ Requires-Dist: ruff>=0.14 ; extra == 'style'
40
+ Requires-Dist: ty>=0.0.1a23 ; extra == 'style'
41
+ Requires-Dist: pytest>=8 ; extra == 'tests'
42
+ Requires-Dist: pytest-cov>=5 ; extra == 'tests'
43
+ Requires-Dist: pytest-socket>=0.7 ; extra == 'tests'
44
+ Requires-Python: >=3.13
45
+ Project-URL: Homepage, https://research.taylorgeospatial.org/neuralftw/
46
+ Project-URL: Repository, https://github.com/taylor-geospatial/neuralftw
47
+ Project-URL: Issues, https://github.com/taylor-geospatial/neuralftw/issues
48
+ Project-URL: Model Zoo, https://huggingface.co/taylor-geospatial/neuralftw-zoo
49
+ Project-URL: Leaderboard, https://research.taylorgeospatial.org/neuralftw/
50
+ Project-URL: Live Demo, https://research.taylorgeospatial.org/neuralftw/demo.html
51
+ Provides-Extra: all
52
+ Provides-Extra: products
53
+ Provides-Extra: style
54
+ Provides-Extra: tests
55
+ Description-Content-Type: text/markdown
56
+
57
+ # NeuralFTW
58
+
59
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/taylor-geospatial/neuralftw/blob/main/LICENSE)
60
+ [![Python 3.13+](https://img.shields.io/badge/python-3.13%2B-blue.svg)](https://www.python.org/downloads/)
61
+ [![Leaderboard](https://img.shields.io/badge/CoordBench-Leaderboard-0ea5e9.svg)](https://research.taylorgeospatial.org/neuralftw/)
62
+ [![WebGPU Demo](https://img.shields.io/badge/WebGPU-Live%20Demo-22c55e.svg)](https://research.taylorgeospatial.org/neuralftw/demo.html)
63
+
64
+ **NeuralFTW** is a pure-PyTorch library for geographic Implicit Neural Representations (INRs), coordinate encoders, embedding raster products, and **CoordBench** downstream evaluation.
65
+
66
+ Every encoder in NeuralFTW implements a single `torch.nn.Module` contract (`LocationEncoder`), loads stripped `safetensors` checkpoints with zero third-party wrapper dependencies (`rshf`, `geoclip`, `transformers`, or runtime `git clone`s are not required), and evaluates cleanly across random, regional block-CV, buffered-exclusion, and urban/rural splits.
67
+
68
+ - **CoordBench Leaderboard**: https://research.taylorgeospatial.org/neuralftw/
69
+ - **Live Browser WebGPU Demo**: https://research.taylorgeospatial.org/neuralftw/demo.html
70
+ - **Model Zoo (Safetensors + ONNX FP32/FP16/INT8/INT4)**: https://huggingface.co/taylor-geospatial/neuralftw-zoo
71
+
72
+ ## Installation
73
+
74
+ ```bash
75
+ pip install neuralftw
76
+ ```
77
+
78
+ Optional extra (only needed for streaming cloud Zarr embedding products):
79
+
80
+ ```bash
81
+ # AlphaEarth & TESSERA Zarr embedding products (zarr, s3fs, pyproj, requests, numcodecs)
82
+ pip install 'neuralftw[products]'
83
+ ```
84
+
85
+ `onnxruntime`, `matplotlib`, and `torchid>=0.6.0` (pure PyTorch, no FAISS) are included by default.
86
+
87
+ ## Universal Input/Output Contract
88
+
89
+ - **Spatial input**: Every `LocationEncoder` accepts `(lon, lat)` coordinates in **WGS84 degrees** (`EPSG:4326` / GeoJSON order) with dynamic batch shape `(B, 2)` in `forward(coords, year=None, month=None)` and 1D arrays `(lon, lat)` in `encode(lon, lat, year=None, month=None)`. Models whose upstream weights expect `(lat, lon)` (MIND, GeoCLIP, TaxaBind, SLED, TTE, GT-Loc) handle the swap internally.
90
+ - **Temporal input**: Optional `year` (and `month` for Climplicit) are supported directly on `forward` / `encode` with explicit defaults documented below.
91
+ - **Output**: `float32` embeddings of shape `(B, embed_dim)`.
92
+
93
+ ## Model & Input/Output Contract Table
94
+
95
+ All 26 location-encoder-only checkpoints are hosted in [`taylor-geospatial/neuralftw-zoo`](https://huggingface.co/taylor-geospatial/neuralftw-zoo) as stripped `<model_id>/model.safetensors` weights and self-contained dynamic-batch ONNX graphs (`model.onnx`, plus quantized `model_fp16.onnx`, `model_int8.onnx`, and `model_int4_bs32.onnx` across the 24 spatial models and quantized `mind`), reproducible via [`scripts/export_zoo.py`](https://github.com/taylor-geospatial/neuralftw/blob/main/scripts/export_zoo.py) and [`scripts/export_onnx.py`](https://github.com/taylor-geospatial/neuralftw/blob/main/scripts/export_onnx.py). MIND FP32 weights remain hosted at [`taylor-geospatial/MIND`](https://huggingface.co/taylor-geospatial/MIND). For upcoming and requested encoders not yet integrated, see [`docs/CANDIDATE_MODELS.md`](https://github.com/taylor-geospatial/neuralftw/blob/main/docs/CANDIDATE_MODELS.md).
96
+
97
+ | Preset | Family | Spatial Input | Temporal Input (Default) | Output `embed_dim` | Weight Source | Stripped Size | License |
98
+ |---|---|---|---|---:|---|---:|---|
99
+ | `sincos` | Analytic | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 4 | None | — | MIT |
100
+ | `xyz` | Analytic | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 3 | None | — | MIT |
101
+ | `nerf` | Analytic | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 96 | None | — | MIT |
102
+ | `spherical-harmonics` | Analytic | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 16 | None | — | MIT |
103
+ | `sh40` | Analytic | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 1681 | None | — | MIT |
104
+ | `rff3072` | Analytic | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 3072 | None | — | MIT |
105
+ | `mind` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Optional `year` (`2021`) | 64 | `taylor-geospatial/MIND` | 216.5 MiB | MIT |
106
+ | `mind-3072` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Optional `year` (`2021`) | 3072 | `taylor-geospatial/MIND` | 216.5 MiB | MIT |
107
+ | `mind-head` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Optional `year` (`2021`) | 64 | `taylor-geospatial/MIND` | 216.5 MiB | MIT |
108
+ | `satclip` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 4.85 MB | MIT |
109
+ | `satclip-vit16-l10` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 1.78 MB | MIT |
110
+ | `satclip-resnet18-l40` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 4.85 MB | MIT |
111
+ | `satclip-resnet18-l10` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 1.78 MB | MIT |
112
+ | `satclip-resnet50-l40` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 4.85 MB | MIT |
113
+ | `satclip-resnet50-l10` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 1.78 MB | MIT |
114
+ | `geoclip` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 512 | `taylor-geospatial/neuralftw-zoo` | 37.8 MB | MIT |
115
+ | `sinr` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 2.11 MB | MIT |
116
+ | `climplicit` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Optional `month` 1–12 (`[3,6,9,12]` concat) | 1024 (256 w/ `month`) | `taylor-geospatial/neuralftw-zoo` | 16.3 MB | CC-BY-4.0 |
117
+ | `gair` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 768 | `taylor-geospatial/neuralftw-zoo` | 40.9 MB | Apache-2.0 |
118
+ | `taxabind` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 512 | `taylor-geospatial/neuralftw-zoo` | 37.8 MB | Apache-2.0 |
119
+ | `sled` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 768 | `taylor-geospatial/neuralftw-zoo` | 56.7 MB | Apache-2.0 |
120
+ | `sled-s2` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 768 | `taylor-geospatial/neuralftw-zoo` | 56.7 MB | Apache-2.0 |
121
+ | `tte` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 512 | `taylor-geospatial/neuralftw-zoo` | 13.7 MB | MIT |
122
+ | `terranova` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 200.8 MB | CC-BY-4.0 |
123
+ | `terranova-st` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Optional `year` 1900–2035 (`2020`) | 256 | `taylor-geospatial/neuralftw-zoo` | 614.9 MB | CC-BY-4.0 |
124
+ | `csp-inat` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 0.79 MB | Unlicensed (pending author confirmation) |
125
+ | `csp-fmow` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 0.79 MB | Unlicensed (pending author confirmation) |
126
+ | `osmgraphclip` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 4.86 MB | Apache-2.0 |
127
+ | `osmgraphclip-ms-l10` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 1.78 MB | Apache-2.0 |
128
+ | `osmgraphclip-a-l40` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 4.86 MB | Apache-2.0 |
129
+ | `osmgraphclip-a-l10` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 1.78 MB | Apache-2.0 |
130
+ | `le-sinr` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 2.37 MB | MIT |
131
+ | `gtloc` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 512 | `taylor-geospatial/neuralftw-zoo` | 37.8 MB | CC-BY-NC-4.0 |
132
+ | `hydroloc` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 512 (MRL 64/128/256/512) | `taylor-geospatial/neuralftw-zoo` | 4.21 MB | Apache-2.0 |
133
+ | `geoclosp` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 384 | `taylor-geospatial/neuralftw-zoo` | 2.18 MB | CreativeML-OpenRAIL-M |
134
+ | `aef` | Embedding Product | `(lon, lat)` deg, `(B, 2)` | Optional `year` 2017–2025 (`2021`) | 64 | Zarr S3 (`tge-labs/aef-mosaic`) | Streams on demand | CC-BY-4.0 |
135
+ | `tessera` | Embedding Product | `(lon, lat)` deg, `(B, 2)` | Optional `year` 2017–2025 (`2021`) | 128 | Zarr S3 (`tessera/v1.1-dclimate`) | Streams on demand | CC-BY-4.0 |
136
+
137
+ > **License & attribution note**: Code in this repository is MIT-licensed. Bundled urban/rural city coordinates (`cities15000.parquet`) are derived from [GeoNames](https://www.geonames.org/) under CC-BY-4.0. Individual pretrained checkpoints carry their respective upstream licenses (including CC-BY-4.0 attribution for Climplicit, TerraNova, AlphaEarth, and TESSERA; **CC-BY-NC-4.0** non-commercial for GT-Loc; **CreativeML-OpenRAIL-M** for GeoCLOSP-RN; MIT for LE-SINR; and Apache-2.0 for HydroLoc, trained by Isaac Corley on [`isaaccorley/hydro`](https://huggingface.co/datasets/isaaccorley/hydro) with no associated paper). `csp-inat` and `csp-fmow` weights originate from the upstream CSP release (Mai et al., ICML 2023) without an explicit license file and are marked unlicensed pending author confirmation.
138
+
139
+ ## Python API Quickstart
140
+
141
+ ### Direct PyTorch `nn.Module` & Batched NumPy Inference
142
+
143
+ ```python
144
+ import numpy as np
145
+ import torch
146
+
147
+ import neuralftw
148
+
149
+ # Inspect all 37 registered presets (no heavy imports required)
150
+ print(neuralftw.list_models())
151
+
152
+ # Load via registry preset (or neuralftw.models.SatCLIPLocationEncoder(...))
153
+ encoder = neuralftw.get_model('mind', device='cpu')
154
+
155
+ # 1. Direct nn.Module forward pass on (lon, lat) WGS84 degrees
156
+ coords = torch.tensor([[-122.4194, 37.7749], [8.5417, 47.3769]])
157
+ emb = encoder(coords) # shape: (2, 64), dtype: float32
158
+
159
+ # 2. Chunked NumPy inference with optional year / month
160
+ lon = np.array([-122.4194, 8.5417])
161
+ lat = np.array([37.7749, 47.3769])
162
+ year = np.array([2021, 2023])
163
+ features = encoder.encode(lon, lat, year=year) # shape: (2, 64), dtype: float32
164
+
165
+ # 3. ONNX Runtime backend with quantized weights (FP32, FP16, INT8, INT4)
166
+ onnx_enc = neuralftw.get_model('geoclip', backend='onnx', precision='int8')
167
+ onnx_features = onnx_enc.encode(lon, lat) # shape: (2, 512), dtype: float32
168
+ ```
169
+
170
+ ### Grid Inference & Plotting
171
+
172
+ Generate a regular `(lon, lat)` grid, run batched inference, and project embeddings to RGB:
173
+
174
+ ```python
175
+ import neuralftw
176
+
177
+ # Global 1-degree grid (or pass bounds=(lon_min, lat_min, lon_max, lat_max) for a region)
178
+ lon, lat, emb = neuralftw.encode_grid('sinr', step_deg=1.0, batch_size=8192)
179
+
180
+ # Pure-NumPy PCA RGB projection (works without matplotlib)
181
+ rgb = neuralftw.embeddings_to_rgb(emb, components=(0, 1, 2))
182
+
183
+ # Or plot directly with matplotlib
184
+ fig, ax = neuralftw.plot_embedding_map(lon, lat, emb, title='SINR (PC 1–3)')
185
+ ```
186
+
187
+ ### Adding a Custom Model
188
+
189
+ Subclass `neuralftw.LocationEncoder` and implement `forward(coords, year=None, month=None)` accepting `(B, 2)` `(lon, lat)` degrees. You can register it in Python or pass it directly to the CLI:
190
+
191
+ ```python
192
+ import torch
193
+ from torch import Tensor
194
+
195
+ import neuralftw
196
+
197
+
198
+ @neuralftw.register_model('my-encoder', description='Custom coordinate MLP.')
199
+ class MyEncoder(neuralftw.LocationEncoder):
200
+ name = 'my-encoder'
201
+ embed_dim = 64
202
+
203
+ def __init__(self, hidden_dim: int = 128, device: str = 'cpu') -> None:
204
+ super().__init__(device=device)
205
+ self.net = torch.nn.Sequential(
206
+ torch.nn.Linear(2, hidden_dim),
207
+ torch.nn.GELU(),
208
+ torch.nn.Linear(hidden_dim, self.embed_dim),
209
+ ).to(self.device)
210
+
211
+ def forward(
212
+ self, coords: Tensor, year: Tensor | None = None, month: Tensor | None = None
213
+ ) -> Tensor:
214
+ return self.net(coords.to(torch.float32))
215
+
216
+
217
+ enc = neuralftw.get_model('my-encoder', hidden_dim=256)
218
+ lon, lat, emb = neuralftw.encode_grid(enc, step_deg=2.0)
219
+ ```
220
+
221
+ Or evaluate any importable `LocationEncoder` subclass directly from the CLI without writing a YAML config:
222
+
223
+ ```bash
224
+ neuralftw coord \
225
+ --model my-encoder \
226
+ --target my_pkg.models.MyEncoder \
227
+ --model-kwarg hidden_dim=256 \
228
+ --datasets worldclim air_temp \
229
+ --split both
230
+ ```
231
+
232
+ ### Downstream Probing & Spatial Baselines
233
+
234
+ ```python
235
+ from neuralftw.probes import (
236
+ chunked_probe_score,
237
+ kriging_probe_score,
238
+ linear_probe_score,
239
+ spatial_fold_ids,
240
+ )
241
+
242
+ # Nested-CV Ridge probe with exact unpenalized intercept
243
+ r2, fold_r2s = linear_probe_score(features, targets, task_type='regression', folds=5)
244
+
245
+ # Generalized Tikhonov / Chunked Penalty probe for MRL-ordered embeddings
246
+ r2_cp, _ = chunked_probe_score(features, targets, task_type='regression', folds=5)
247
+
248
+ # Spatial block cross-validation & encoder-free Ordinary/Indicator Kriging baseline
249
+ folds = spatial_fold_ids(lat, lon, folds=5, cell_deg=10.0, seed=0)
250
+ krig_r2, _ = kriging_probe_score(lat, lon, targets, fold_assign=folds, cell_deg=10.0)
251
+ ```
252
+
253
+ ### Programmatic CoordBench Evaluation
254
+
255
+ ```python
256
+ from neuralftw.coordbench import (
257
+ CoordConfig,
258
+ CoordEvaluationConfig,
259
+ CoordModelConfig,
260
+ CoordOutputConfig,
261
+ run_coordbench,
262
+ )
263
+
264
+ cfg = CoordConfig(
265
+ model=CoordModelConfig(name='satclip'),
266
+ datasets=('worldclim', 'air_temp'),
267
+ evaluation=CoordEvaluationConfig(
268
+ methods=('linear',), split='both', cell_deg=(2.0, 10.0, 20.0)
269
+ ),
270
+ output=CoordOutputConfig(file='results/satclip.csv', resume=True),
271
+ )
272
+ results = run_coordbench(cfg)
273
+ ```
274
+
275
+ ## CLI Quickstart
276
+
277
+ `neuralftw models`, `neuralftw datasets`, and `neuralftw coord --dry-run` start instantaneously without importing `torch`, `numpy`, or `pandas`.
278
+
279
+ ```bash
280
+ # List registered model presets or inspect a single preset YAML
281
+ neuralftw models
282
+ neuralftw models mind
283
+
284
+ # List CoordBench dataset families and benchmark names
285
+ neuralftw datasets
286
+ neuralftw datasets --official
287
+
288
+ # Validate configuration and inspect effective YAML without running
289
+ neuralftw coord --model mind --datasets official --split both --cell-deg 2 10 20 --dry-run
290
+
291
+ # Run random + multi-cell regional sweep with atomic CSV resume
292
+ neuralftw coord \
293
+ --model satclip \
294
+ --datasets worldclim satclip-air-temp \
295
+ --methods linear \
296
+ --split both \
297
+ --cell-deg 2 10 20 40 \
298
+ --output results/coordbench.csv \
299
+ --resume
300
+
301
+ # Run urban/rural stratified or holdout evaluation (uses bundled GeoNames cities15000)
302
+ neuralftw coord \
303
+ --model mind \
304
+ --datasets worldclim-bio1 satclip-country \
305
+ --methods linear chunked \
306
+ --split urban_rural_holdout \
307
+ --output results/urban_rural.csv
308
+
309
+ # Run encoder-free spatial interpolation baselines (IDW or Ordinary/Indicator Kriging)
310
+ neuralftw coord --model kriging --methods kriging --datasets air_temp --split spatial --cell-deg 10
311
+
312
+ # Summarize results CSV into per-family and macro rankings
313
+ neuralftw leaderboard results/coordbench_results.csv --method linear --split spatial
314
+ ```
315
+
316
+ ## Benchmarks & Analysis
317
+
318
+ - **CoordBench Leaderboard**: [interactive leaderboard](https://research.taylorgeospatial.org/neuralftw/) backed by [`results/coordbench_results.csv`](https://github.com/taylor-geospatial/neuralftw/blob/main/results/coordbench_results.csv).
319
+ - **Implicit Spatial Resolution & Intrinsic Dimension**: half-sill distances, suggested sampling grids, and `torchid` intrinsic dimensionality across 35 encoders in [`docs/IMPLICIT_RESOLUTION.md`](https://github.com/taylor-geospatial/neuralftw/blob/main/docs/IMPLICIT_RESOLUTION.md) ([`implicit_resolution.csv`](https://github.com/taylor-geospatial/neuralftw/blob/main/results/implicit_resolution.csv), [`intrinsic_dim.csv`](https://github.com/taylor-geospatial/neuralftw/blob/main/results/intrinsic_dim.csv)).
320
+ - **ONNX Quantization**: FP32, mixed-FP16, weight-only INT8/INT4, and browser WebGPU benchmarks in [`docs/QUANTIZATION.md`](https://github.com/taylor-geospatial/neuralftw/blob/main/docs/QUANTIZATION.md).
321
+
322
+ ## License
323
+
324
+ NeuralFTW is released under the [MIT License](https://github.com/taylor-geospatial/neuralftw/blob/main/LICENSE). Copyright (c) Taylor Geospatial.
@@ -0,0 +1,268 @@
1
+ # NeuralFTW
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/taylor-geospatial/neuralftw/blob/main/LICENSE)
4
+ [![Python 3.13+](https://img.shields.io/badge/python-3.13%2B-blue.svg)](https://www.python.org/downloads/)
5
+ [![Leaderboard](https://img.shields.io/badge/CoordBench-Leaderboard-0ea5e9.svg)](https://research.taylorgeospatial.org/neuralftw/)
6
+ [![WebGPU Demo](https://img.shields.io/badge/WebGPU-Live%20Demo-22c55e.svg)](https://research.taylorgeospatial.org/neuralftw/demo.html)
7
+
8
+ **NeuralFTW** is a pure-PyTorch library for geographic Implicit Neural Representations (INRs), coordinate encoders, embedding raster products, and **CoordBench** downstream evaluation.
9
+
10
+ Every encoder in NeuralFTW implements a single `torch.nn.Module` contract (`LocationEncoder`), loads stripped `safetensors` checkpoints with zero third-party wrapper dependencies (`rshf`, `geoclip`, `transformers`, or runtime `git clone`s are not required), and evaluates cleanly across random, regional block-CV, buffered-exclusion, and urban/rural splits.
11
+
12
+ - **CoordBench Leaderboard**: https://research.taylorgeospatial.org/neuralftw/
13
+ - **Live Browser WebGPU Demo**: https://research.taylorgeospatial.org/neuralftw/demo.html
14
+ - **Model Zoo (Safetensors + ONNX FP32/FP16/INT8/INT4)**: https://huggingface.co/taylor-geospatial/neuralftw-zoo
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pip install neuralftw
20
+ ```
21
+
22
+ Optional extra (only needed for streaming cloud Zarr embedding products):
23
+
24
+ ```bash
25
+ # AlphaEarth & TESSERA Zarr embedding products (zarr, s3fs, pyproj, requests, numcodecs)
26
+ pip install 'neuralftw[products]'
27
+ ```
28
+
29
+ `onnxruntime`, `matplotlib`, and `torchid>=0.6.0` (pure PyTorch, no FAISS) are included by default.
30
+
31
+ ## Universal Input/Output Contract
32
+
33
+ - **Spatial input**: Every `LocationEncoder` accepts `(lon, lat)` coordinates in **WGS84 degrees** (`EPSG:4326` / GeoJSON order) with dynamic batch shape `(B, 2)` in `forward(coords, year=None, month=None)` and 1D arrays `(lon, lat)` in `encode(lon, lat, year=None, month=None)`. Models whose upstream weights expect `(lat, lon)` (MIND, GeoCLIP, TaxaBind, SLED, TTE, GT-Loc) handle the swap internally.
34
+ - **Temporal input**: Optional `year` (and `month` for Climplicit) are supported directly on `forward` / `encode` with explicit defaults documented below.
35
+ - **Output**: `float32` embeddings of shape `(B, embed_dim)`.
36
+
37
+ ## Model & Input/Output Contract Table
38
+
39
+ All 26 location-encoder-only checkpoints are hosted in [`taylor-geospatial/neuralftw-zoo`](https://huggingface.co/taylor-geospatial/neuralftw-zoo) as stripped `<model_id>/model.safetensors` weights and self-contained dynamic-batch ONNX graphs (`model.onnx`, plus quantized `model_fp16.onnx`, `model_int8.onnx`, and `model_int4_bs32.onnx` across the 24 spatial models and quantized `mind`), reproducible via [`scripts/export_zoo.py`](https://github.com/taylor-geospatial/neuralftw/blob/main/scripts/export_zoo.py) and [`scripts/export_onnx.py`](https://github.com/taylor-geospatial/neuralftw/blob/main/scripts/export_onnx.py). MIND FP32 weights remain hosted at [`taylor-geospatial/MIND`](https://huggingface.co/taylor-geospatial/MIND). For upcoming and requested encoders not yet integrated, see [`docs/CANDIDATE_MODELS.md`](https://github.com/taylor-geospatial/neuralftw/blob/main/docs/CANDIDATE_MODELS.md).
40
+
41
+ | Preset | Family | Spatial Input | Temporal Input (Default) | Output `embed_dim` | Weight Source | Stripped Size | License |
42
+ |---|---|---|---|---:|---|---:|---|
43
+ | `sincos` | Analytic | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 4 | None | — | MIT |
44
+ | `xyz` | Analytic | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 3 | None | — | MIT |
45
+ | `nerf` | Analytic | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 96 | None | — | MIT |
46
+ | `spherical-harmonics` | Analytic | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 16 | None | — | MIT |
47
+ | `sh40` | Analytic | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 1681 | None | — | MIT |
48
+ | `rff3072` | Analytic | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 3072 | None | — | MIT |
49
+ | `mind` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Optional `year` (`2021`) | 64 | `taylor-geospatial/MIND` | 216.5 MiB | MIT |
50
+ | `mind-3072` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Optional `year` (`2021`) | 3072 | `taylor-geospatial/MIND` | 216.5 MiB | MIT |
51
+ | `mind-head` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Optional `year` (`2021`) | 64 | `taylor-geospatial/MIND` | 216.5 MiB | MIT |
52
+ | `satclip` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 4.85 MB | MIT |
53
+ | `satclip-vit16-l10` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 1.78 MB | MIT |
54
+ | `satclip-resnet18-l40` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 4.85 MB | MIT |
55
+ | `satclip-resnet18-l10` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 1.78 MB | MIT |
56
+ | `satclip-resnet50-l40` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 4.85 MB | MIT |
57
+ | `satclip-resnet50-l10` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 1.78 MB | MIT |
58
+ | `geoclip` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 512 | `taylor-geospatial/neuralftw-zoo` | 37.8 MB | MIT |
59
+ | `sinr` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 2.11 MB | MIT |
60
+ | `climplicit` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Optional `month` 1–12 (`[3,6,9,12]` concat) | 1024 (256 w/ `month`) | `taylor-geospatial/neuralftw-zoo` | 16.3 MB | CC-BY-4.0 |
61
+ | `gair` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 768 | `taylor-geospatial/neuralftw-zoo` | 40.9 MB | Apache-2.0 |
62
+ | `taxabind` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 512 | `taylor-geospatial/neuralftw-zoo` | 37.8 MB | Apache-2.0 |
63
+ | `sled` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 768 | `taylor-geospatial/neuralftw-zoo` | 56.7 MB | Apache-2.0 |
64
+ | `sled-s2` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 768 | `taylor-geospatial/neuralftw-zoo` | 56.7 MB | Apache-2.0 |
65
+ | `tte` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 512 | `taylor-geospatial/neuralftw-zoo` | 13.7 MB | MIT |
66
+ | `terranova` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 200.8 MB | CC-BY-4.0 |
67
+ | `terranova-st` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Optional `year` 1900–2035 (`2020`) | 256 | `taylor-geospatial/neuralftw-zoo` | 614.9 MB | CC-BY-4.0 |
68
+ | `csp-inat` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 0.79 MB | Unlicensed (pending author confirmation) |
69
+ | `csp-fmow` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 0.79 MB | Unlicensed (pending author confirmation) |
70
+ | `osmgraphclip` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 4.86 MB | Apache-2.0 |
71
+ | `osmgraphclip-ms-l10` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 1.78 MB | Apache-2.0 |
72
+ | `osmgraphclip-a-l40` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 4.86 MB | Apache-2.0 |
73
+ | `osmgraphclip-a-l10` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 1.78 MB | Apache-2.0 |
74
+ | `le-sinr` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 256 | `taylor-geospatial/neuralftw-zoo` | 2.37 MB | MIT |
75
+ | `gtloc` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 512 | `taylor-geospatial/neuralftw-zoo` | 37.8 MB | CC-BY-NC-4.0 |
76
+ | `hydroloc` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 512 (MRL 64/128/256/512) | `taylor-geospatial/neuralftw-zoo` | 4.21 MB | Apache-2.0 |
77
+ | `geoclosp` | Neural INR | `(lon, lat)` deg, `(B, 2)` | Time-invariant | 384 | `taylor-geospatial/neuralftw-zoo` | 2.18 MB | CreativeML-OpenRAIL-M |
78
+ | `aef` | Embedding Product | `(lon, lat)` deg, `(B, 2)` | Optional `year` 2017–2025 (`2021`) | 64 | Zarr S3 (`tge-labs/aef-mosaic`) | Streams on demand | CC-BY-4.0 |
79
+ | `tessera` | Embedding Product | `(lon, lat)` deg, `(B, 2)` | Optional `year` 2017–2025 (`2021`) | 128 | Zarr S3 (`tessera/v1.1-dclimate`) | Streams on demand | CC-BY-4.0 |
80
+
81
+ > **License & attribution note**: Code in this repository is MIT-licensed. Bundled urban/rural city coordinates (`cities15000.parquet`) are derived from [GeoNames](https://www.geonames.org/) under CC-BY-4.0. Individual pretrained checkpoints carry their respective upstream licenses (including CC-BY-4.0 attribution for Climplicit, TerraNova, AlphaEarth, and TESSERA; **CC-BY-NC-4.0** non-commercial for GT-Loc; **CreativeML-OpenRAIL-M** for GeoCLOSP-RN; MIT for LE-SINR; and Apache-2.0 for HydroLoc, trained by Isaac Corley on [`isaaccorley/hydro`](https://huggingface.co/datasets/isaaccorley/hydro) with no associated paper). `csp-inat` and `csp-fmow` weights originate from the upstream CSP release (Mai et al., ICML 2023) without an explicit license file and are marked unlicensed pending author confirmation.
82
+
83
+ ## Python API Quickstart
84
+
85
+ ### Direct PyTorch `nn.Module` & Batched NumPy Inference
86
+
87
+ ```python
88
+ import numpy as np
89
+ import torch
90
+
91
+ import neuralftw
92
+
93
+ # Inspect all 37 registered presets (no heavy imports required)
94
+ print(neuralftw.list_models())
95
+
96
+ # Load via registry preset (or neuralftw.models.SatCLIPLocationEncoder(...))
97
+ encoder = neuralftw.get_model('mind', device='cpu')
98
+
99
+ # 1. Direct nn.Module forward pass on (lon, lat) WGS84 degrees
100
+ coords = torch.tensor([[-122.4194, 37.7749], [8.5417, 47.3769]])
101
+ emb = encoder(coords) # shape: (2, 64), dtype: float32
102
+
103
+ # 2. Chunked NumPy inference with optional year / month
104
+ lon = np.array([-122.4194, 8.5417])
105
+ lat = np.array([37.7749, 47.3769])
106
+ year = np.array([2021, 2023])
107
+ features = encoder.encode(lon, lat, year=year) # shape: (2, 64), dtype: float32
108
+
109
+ # 3. ONNX Runtime backend with quantized weights (FP32, FP16, INT8, INT4)
110
+ onnx_enc = neuralftw.get_model('geoclip', backend='onnx', precision='int8')
111
+ onnx_features = onnx_enc.encode(lon, lat) # shape: (2, 512), dtype: float32
112
+ ```
113
+
114
+ ### Grid Inference & Plotting
115
+
116
+ Generate a regular `(lon, lat)` grid, run batched inference, and project embeddings to RGB:
117
+
118
+ ```python
119
+ import neuralftw
120
+
121
+ # Global 1-degree grid (or pass bounds=(lon_min, lat_min, lon_max, lat_max) for a region)
122
+ lon, lat, emb = neuralftw.encode_grid('sinr', step_deg=1.0, batch_size=8192)
123
+
124
+ # Pure-NumPy PCA RGB projection (works without matplotlib)
125
+ rgb = neuralftw.embeddings_to_rgb(emb, components=(0, 1, 2))
126
+
127
+ # Or plot directly with matplotlib
128
+ fig, ax = neuralftw.plot_embedding_map(lon, lat, emb, title='SINR (PC 1–3)')
129
+ ```
130
+
131
+ ### Adding a Custom Model
132
+
133
+ Subclass `neuralftw.LocationEncoder` and implement `forward(coords, year=None, month=None)` accepting `(B, 2)` `(lon, lat)` degrees. You can register it in Python or pass it directly to the CLI:
134
+
135
+ ```python
136
+ import torch
137
+ from torch import Tensor
138
+
139
+ import neuralftw
140
+
141
+
142
+ @neuralftw.register_model('my-encoder', description='Custom coordinate MLP.')
143
+ class MyEncoder(neuralftw.LocationEncoder):
144
+ name = 'my-encoder'
145
+ embed_dim = 64
146
+
147
+ def __init__(self, hidden_dim: int = 128, device: str = 'cpu') -> None:
148
+ super().__init__(device=device)
149
+ self.net = torch.nn.Sequential(
150
+ torch.nn.Linear(2, hidden_dim),
151
+ torch.nn.GELU(),
152
+ torch.nn.Linear(hidden_dim, self.embed_dim),
153
+ ).to(self.device)
154
+
155
+ def forward(
156
+ self, coords: Tensor, year: Tensor | None = None, month: Tensor | None = None
157
+ ) -> Tensor:
158
+ return self.net(coords.to(torch.float32))
159
+
160
+
161
+ enc = neuralftw.get_model('my-encoder', hidden_dim=256)
162
+ lon, lat, emb = neuralftw.encode_grid(enc, step_deg=2.0)
163
+ ```
164
+
165
+ Or evaluate any importable `LocationEncoder` subclass directly from the CLI without writing a YAML config:
166
+
167
+ ```bash
168
+ neuralftw coord \
169
+ --model my-encoder \
170
+ --target my_pkg.models.MyEncoder \
171
+ --model-kwarg hidden_dim=256 \
172
+ --datasets worldclim air_temp \
173
+ --split both
174
+ ```
175
+
176
+ ### Downstream Probing & Spatial Baselines
177
+
178
+ ```python
179
+ from neuralftw.probes import (
180
+ chunked_probe_score,
181
+ kriging_probe_score,
182
+ linear_probe_score,
183
+ spatial_fold_ids,
184
+ )
185
+
186
+ # Nested-CV Ridge probe with exact unpenalized intercept
187
+ r2, fold_r2s = linear_probe_score(features, targets, task_type='regression', folds=5)
188
+
189
+ # Generalized Tikhonov / Chunked Penalty probe for MRL-ordered embeddings
190
+ r2_cp, _ = chunked_probe_score(features, targets, task_type='regression', folds=5)
191
+
192
+ # Spatial block cross-validation & encoder-free Ordinary/Indicator Kriging baseline
193
+ folds = spatial_fold_ids(lat, lon, folds=5, cell_deg=10.0, seed=0)
194
+ krig_r2, _ = kriging_probe_score(lat, lon, targets, fold_assign=folds, cell_deg=10.0)
195
+ ```
196
+
197
+ ### Programmatic CoordBench Evaluation
198
+
199
+ ```python
200
+ from neuralftw.coordbench import (
201
+ CoordConfig,
202
+ CoordEvaluationConfig,
203
+ CoordModelConfig,
204
+ CoordOutputConfig,
205
+ run_coordbench,
206
+ )
207
+
208
+ cfg = CoordConfig(
209
+ model=CoordModelConfig(name='satclip'),
210
+ datasets=('worldclim', 'air_temp'),
211
+ evaluation=CoordEvaluationConfig(
212
+ methods=('linear',), split='both', cell_deg=(2.0, 10.0, 20.0)
213
+ ),
214
+ output=CoordOutputConfig(file='results/satclip.csv', resume=True),
215
+ )
216
+ results = run_coordbench(cfg)
217
+ ```
218
+
219
+ ## CLI Quickstart
220
+
221
+ `neuralftw models`, `neuralftw datasets`, and `neuralftw coord --dry-run` start instantaneously without importing `torch`, `numpy`, or `pandas`.
222
+
223
+ ```bash
224
+ # List registered model presets or inspect a single preset YAML
225
+ neuralftw models
226
+ neuralftw models mind
227
+
228
+ # List CoordBench dataset families and benchmark names
229
+ neuralftw datasets
230
+ neuralftw datasets --official
231
+
232
+ # Validate configuration and inspect effective YAML without running
233
+ neuralftw coord --model mind --datasets official --split both --cell-deg 2 10 20 --dry-run
234
+
235
+ # Run random + multi-cell regional sweep with atomic CSV resume
236
+ neuralftw coord \
237
+ --model satclip \
238
+ --datasets worldclim satclip-air-temp \
239
+ --methods linear \
240
+ --split both \
241
+ --cell-deg 2 10 20 40 \
242
+ --output results/coordbench.csv \
243
+ --resume
244
+
245
+ # Run urban/rural stratified or holdout evaluation (uses bundled GeoNames cities15000)
246
+ neuralftw coord \
247
+ --model mind \
248
+ --datasets worldclim-bio1 satclip-country \
249
+ --methods linear chunked \
250
+ --split urban_rural_holdout \
251
+ --output results/urban_rural.csv
252
+
253
+ # Run encoder-free spatial interpolation baselines (IDW or Ordinary/Indicator Kriging)
254
+ neuralftw coord --model kriging --methods kriging --datasets air_temp --split spatial --cell-deg 10
255
+
256
+ # Summarize results CSV into per-family and macro rankings
257
+ neuralftw leaderboard results/coordbench_results.csv --method linear --split spatial
258
+ ```
259
+
260
+ ## Benchmarks & Analysis
261
+
262
+ - **CoordBench Leaderboard**: [interactive leaderboard](https://research.taylorgeospatial.org/neuralftw/) backed by [`results/coordbench_results.csv`](https://github.com/taylor-geospatial/neuralftw/blob/main/results/coordbench_results.csv).
263
+ - **Implicit Spatial Resolution & Intrinsic Dimension**: half-sill distances, suggested sampling grids, and `torchid` intrinsic dimensionality across 35 encoders in [`docs/IMPLICIT_RESOLUTION.md`](https://github.com/taylor-geospatial/neuralftw/blob/main/docs/IMPLICIT_RESOLUTION.md) ([`implicit_resolution.csv`](https://github.com/taylor-geospatial/neuralftw/blob/main/results/implicit_resolution.csv), [`intrinsic_dim.csv`](https://github.com/taylor-geospatial/neuralftw/blob/main/results/intrinsic_dim.csv)).
264
+ - **ONNX Quantization**: FP32, mixed-FP16, weight-only INT8/INT4, and browser WebGPU benchmarks in [`docs/QUANTIZATION.md`](https://github.com/taylor-geospatial/neuralftw/blob/main/docs/QUANTIZATION.md).
265
+
266
+ ## License
267
+
268
+ NeuralFTW is released under the [MIT License](https://github.com/taylor-geospatial/neuralftw/blob/main/LICENSE). Copyright (c) Taylor Geospatial.