Upload Safecast radiation spatial regressor
Browse files- README.md +162 -0
- config.json +33 -0
- model.safetensors +3 -0
- pytorch_model.bin +3 -0
- reference_hotspots.json +79 -0
- spatial_ensemble_regressor.joblib +3 -0
- spatial_regressor.onnx +3 -0
README.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: cc0-1.0
|
| 5 |
+
tags:
|
| 6 |
+
- tabular-regression
|
| 7 |
+
- spatial-ml
|
| 8 |
+
- radiation
|
| 9 |
+
- safecast
|
| 10 |
+
- environmental-science
|
| 11 |
+
- anomaly-detection
|
| 12 |
+
- pytorch
|
| 13 |
+
- safetensors
|
| 14 |
+
- onnx
|
| 15 |
+
datasets:
|
| 16 |
+
- hsilvosa/safecast-radiation
|
| 17 |
+
metrics:
|
| 18 |
+
- r2
|
| 19 |
+
- rmse
|
| 20 |
+
- mae
|
| 21 |
+
model-index:
|
| 22 |
+
- name: safecast-spatial-harmonic-net
|
| 23 |
+
results:
|
| 24 |
+
- task:
|
| 25 |
+
type: tabular-regression
|
| 26 |
+
name: Global Radiation Spatial Regression
|
| 27 |
+
dataset:
|
| 28 |
+
type: hsilvosa/safecast-radiation
|
| 29 |
+
name: Safecast Historical Radiation Measurements
|
| 30 |
+
metrics:
|
| 31 |
+
- type: r2
|
| 32 |
+
value: 0.0785
|
| 33 |
+
name: R2 Score (log-scale)
|
| 34 |
+
- type: rmse
|
| 35 |
+
value: 3.11636
|
| 36 |
+
name: RMSE (uSv/h)
|
| 37 |
+
- type: mae
|
| 38 |
+
value: 0.67873
|
| 39 |
+
name: MAE (uSv/h)
|
| 40 |
+
---
|
| 41 |
+
|
| 42 |
+
# Global Radiation Anomaly Map & Spatial Regressor (Safecast)
|
| 43 |
+
|
| 44 |
+
## Model Overview
|
| 45 |
+
|
| 46 |
+
This repository provides **SpatialHarmonicNet**, a continuous spatial neural regression model that predicts environmental ambient radiation levels in microsieverts per hour (uSv/h) anywhere on Earth from geographic coordinates (latitude, longitude) and performs real-time radioactive anomaly detection.
|
| 47 |
+
|
| 48 |
+
The model is trained on crowdsourced radiation sensor measurements from the [Safecast Historical Dataset](https://huggingface.co/datasets/hsilvosa/safecast-radiation), which spans over 265 million measurements collected worldwide from 2011 to 2026.
|
| 49 |
+
|
| 50 |
+
## Architecture
|
| 51 |
+
|
| 52 |
+
SpatialHarmonicNet is designed specifically for spherical planetary coordinates:
|
| 53 |
+
|
| 54 |
+
1. **Unit Sphere Projection**: Longitude and latitude in degrees are mapped to 3D Cartesian coordinates on the unit sphere (x, y, z) = (cos(lat)*cos(lon), cos(lat)*sin(lon), sin(lat)), preventing meridian boundary discontinuity at +/-180 degrees and polar distortion.
|
| 55 |
+
2. **Multi-Scale Spherical Fourier Feature Encoding**: Geometric frequency bands project the 3D unit coordinates across harmonic spatial frequencies ranging from planetary dimensions down to localized 1km neighborhoods.
|
| 56 |
+
3. **Deep Residual Backbone**: Multi-layer residual MLP with LayerNorm, SiLU activations, and Dropout.
|
| 57 |
+
4. **Heteroscedastic Gaussian Uncertainty Head**: Predicts both the expected mean log-radiation mu(x) and aleatoric variance sigma^2(x) via Negative Log-Likelihood (NLL) optimization.
|
| 58 |
+
5. **Real-time Anomaly Detection**: Calculates statistical Z-scores and conformal prediction intervals to classify measurements into NORMAL, ELEVATED, ANOMALY_HIGH, and ANOMALY_CRITICAL.
|
| 59 |
+
|
| 60 |
+
## Evaluation Results
|
| 61 |
+
|
| 62 |
+
Evaluation performed on a holdout spatial test split (stratified across global 0.1-degree spatial grid cells):
|
| 63 |
+
|
| 64 |
+
| Metric | SpatialHarmonicNet (PyTorch) |
|
| 65 |
+
| --- | --- |
|
| 66 |
+
| R2 Score (log-scale) | 0.0785 |
|
| 67 |
+
| RMSE (uSv/h) | 3.11636 uSv/h |
|
| 68 |
+
| MAE (uSv/h) | 0.67873 uSv/h |
|
| 69 |
+
| 95% Confidence Interval Coverage (PICP) | 94.3% |
|
| 70 |
+
|
| 71 |
+
### Reference Landmark Verification
|
| 72 |
+
|
| 73 |
+
| Location | Category | Expected / Measured Baseline | Anomaly Trigger (at 5.0 uSv/h) |
|
| 74 |
+
| --- | --- | --- | --- |
|
| 75 |
+
| Chernobyl Reactor 4 Shelter | Nuclear Exclusion Zone | Elevated | ANOMALY_HIGH / CRITICAL |
|
| 76 |
+
| Pripyat Red Forest | Nuclear Exclusion Zone | Elevated | ANOMALY_HIGH / CRITICAL |
|
| 77 |
+
| Fukushima Daiichi | Nuclear Exclusion Zone | Elevated | ANOMALY_HIGH / CRITICAL |
|
| 78 |
+
| Tokyo Metropolitan Area | Urban Background | ~0.05 - 0.08 uSv/h | ANOMALY_CRITICAL (Z > 12) |
|
| 79 |
+
| Paris, France | Urban Background | ~0.06 - 0.09 uSv/h | ANOMALY_CRITICAL (Z > 12) |
|
| 80 |
+
| New York City, USA | Urban Background | ~0.07 - 0.10 uSv/h | ANOMALY_CRITICAL (Z > 12) |
|
| 81 |
+
| Denver, USA (Mile-High) | Elevated Cosmic Background | ~0.12 - 0.16 uSv/h | ANOMALY_CRITICAL (Z > 10) |
|
| 82 |
+
|
| 83 |
+
## Quickstart & Usage
|
| 84 |
+
|
| 85 |
+
### 1. Installation
|
| 86 |
+
|
| 87 |
+
```bash
|
| 88 |
+
pip install torch safetensors numpy pandas scipy
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
### 2. Python Inference Example
|
| 92 |
+
|
| 93 |
+
```python
|
| 94 |
+
import json
|
| 95 |
+
import torch
|
| 96 |
+
from safetensors.torch import load_file
|
| 97 |
+
from radiation_map.models.spatial_net import SpatialHarmonicNet
|
| 98 |
+
from radiation_map.models.anomaly_detector import RadiationAnomalyDetector
|
| 99 |
+
|
| 100 |
+
# 1. Initialize model
|
| 101 |
+
model = SpatialHarmonicNet(num_frequencies=32, max_frequency_log=4.5, hidden_dims=(256, 256, 128, 64))
|
| 102 |
+
state_dict = load_file("model.safetensors")
|
| 103 |
+
model.load_state_dict(state_dict)
|
| 104 |
+
model.eval()
|
| 105 |
+
|
| 106 |
+
# 2. Predict baseline radiation at a coordinate
|
| 107 |
+
# Coordinates for Tokyo (35.6895 N, 139.6917 E)
|
| 108 |
+
pred = model.predict_radiation(latitudes=35.6895, longitudes=139.6917)
|
| 109 |
+
print(f"Predicted baseline: {pred['radiation_usv']:.4f} uSv/h")
|
| 110 |
+
print(f"95% Confidence Interval: [{pred['ci_lower_usv']:.4f}, {pred['ci_upper_usv']:.4f}] uSv/h")
|
| 111 |
+
|
| 112 |
+
# 3. Real-time Anomaly Detection
|
| 113 |
+
detector = RadiationAnomalyDetector(model)
|
| 114 |
+
result = detector.detect(
|
| 115 |
+
latitude=35.6895,
|
| 116 |
+
longitude=139.6917,
|
| 117 |
+
observed_value=2.50, # hypothetical spike in uSv/h
|
| 118 |
+
unit="usv"
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
print(f"Severity: {result.severity.value}")
|
| 122 |
+
print(f"Z-score: {result.z_score:.2f}")
|
| 123 |
+
print(f"Fold increase: {result.fold_increase:.1f}x")
|
| 124 |
+
print(f"Description: {result.description}")
|
| 125 |
+
```
|
| 126 |
+
|
| 127 |
+
### 3. ONNX Runtime Inference
|
| 128 |
+
|
| 129 |
+
```python
|
| 130 |
+
import numpy as np
|
| 131 |
+
import onnxruntime as ort
|
| 132 |
+
|
| 133 |
+
session = ort.InferenceSession("spatial_regressor.onnx")
|
| 134 |
+
|
| 135 |
+
# Project lat/lon to 3D Cartesian coordinates
|
| 136 |
+
lat, lon = np.radians(35.6895), np.radians(139.6917)
|
| 137 |
+
xyz = np.array([[np.cos(lat)*np.cos(lon), np.cos(lat)*np.sin(lon), np.sin(lat)]], dtype=np.float32)
|
| 138 |
+
|
| 139 |
+
inputs = {"coords_cartesian": xyz}
|
| 140 |
+
mu_log, log_var = session.run(None, inputs)
|
| 141 |
+
|
| 142 |
+
# Inverse log transform to get uSv/h
|
| 143 |
+
pred_usv = np.expm1(mu_log[0][0]) / 10.0
|
| 144 |
+
print(f"ONNX Predicted uSv/h: {pred_usv:.4f}")
|
| 145 |
+
```
|
| 146 |
+
|
| 147 |
+
## Intended Use & Limitations
|
| 148 |
+
|
| 149 |
+
- **Intended Use**: Environmental baseline modeling, spatial regression research, citizen-science data exploration, and screening for radioactive anomalies.
|
| 150 |
+
- **Limitations**: Safecast data is crowdsourced and collected with mobile bGeigie Geiger-Muller counters. It is not official regulatory or government monitoring data. Geiger counters measure dose equivalents with Cs-137 calibration approximations.
|
| 151 |
+
|
| 152 |
+
## Citation & Attribution
|
| 153 |
+
|
| 154 |
+
```bibtex
|
| 155 |
+
@misc{safecast_spatial_radiation,
|
| 156 |
+
author = {Safecast Contributors and Project Authors},
|
| 157 |
+
title = {Global Radiation Anomaly Map and Spatial Regressor},
|
| 158 |
+
year = {2026},
|
| 159 |
+
publisher = {Hugging Face},
|
| 160 |
+
howpublished = {\url{https://huggingface.co/models}}
|
| 161 |
+
}
|
| 162 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "spatial_harmonic_net",
|
| 3 |
+
"task": "tabular-regression",
|
| 4 |
+
"domain": "spatial-ml",
|
| 5 |
+
"in_dim": 3,
|
| 6 |
+
"coordinate_system": "WGS84_spherical_cartesian",
|
| 7 |
+
"num_frequencies": 32,
|
| 8 |
+
"max_frequency_log": 4.5,
|
| 9 |
+
"hidden_dims": [
|
| 10 |
+
256,
|
| 11 |
+
256,
|
| 12 |
+
128,
|
| 13 |
+
64
|
| 14 |
+
],
|
| 15 |
+
"cpm_to_usv_factor": 0.002994,
|
| 16 |
+
"target_transform": "log1p_10x",
|
| 17 |
+
"metrics": {
|
| 18 |
+
"r2": 0.0785,
|
| 19 |
+
"rmse_usv": 3.11636,
|
| 20 |
+
"mae_usv": 0.67873,
|
| 21 |
+
"medae_usv": 0.04192,
|
| 22 |
+
"rmse_log": 0.90007,
|
| 23 |
+
"mae_log": 0.43391,
|
| 24 |
+
"picp_95": 0.9434,
|
| 25 |
+
"mpiw_usv": 0.98325,
|
| 26 |
+
"sample_count": 64258
|
| 27 |
+
},
|
| 28 |
+
"anomaly_thresholds": {
|
| 29 |
+
"normal_z_max": 2.0,
|
| 30 |
+
"elevated_z_max": 4.0,
|
| 31 |
+
"anomaly_high_z_max": 8.0
|
| 32 |
+
}
|
| 33 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dd5fe75af43c739b7cb278ad5516a8e52e2276d12f1ed06032c3767c4d6d79dd
|
| 3 |
+
size 1584800
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:00e9822883374fdba9ccae0e8274502b820938263007acee4ee79be0d779b8ed
|
| 3 |
+
size 1594958
|
reference_hotspots.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"Chernobyl_Reactor_4": {
|
| 3 |
+
"latitude": 51.3896,
|
| 4 |
+
"longitude": 30.0999,
|
| 5 |
+
"expected_min_usv": 1.5,
|
| 6 |
+
"category": "hotspot",
|
| 7 |
+
"description": "Chernobyl Nuclear Power Plant Shelter"
|
| 8 |
+
},
|
| 9 |
+
"Pripyat_Red_Forest": {
|
| 10 |
+
"latitude": 51.3833,
|
| 11 |
+
"longitude": 30.05,
|
| 12 |
+
"expected_min_usv": 1.0,
|
| 13 |
+
"category": "hotspot",
|
| 14 |
+
"description": "Pripyat Red Forest Exclusion Zone"
|
| 15 |
+
},
|
| 16 |
+
"Fukushima_Daiichi": {
|
| 17 |
+
"latitude": 37.4211,
|
| 18 |
+
"longitude": 141.0328,
|
| 19 |
+
"expected_min_usv": 0.8,
|
| 20 |
+
"category": "hotspot",
|
| 21 |
+
"description": "Fukushima Daiichi Nuclear Power Station"
|
| 22 |
+
},
|
| 23 |
+
"Futaba_Town_Fukushima": {
|
| 24 |
+
"latitude": 37.4549,
|
| 25 |
+
"longitude": 141.0101,
|
| 26 |
+
"expected_min_usv": 0.4,
|
| 27 |
+
"category": "hotspot",
|
| 28 |
+
"description": "Futaba Exclusion Zone, Fukushima Prefecture"
|
| 29 |
+
},
|
| 30 |
+
"Ramsar_Talesh_Mahalleh": {
|
| 31 |
+
"latitude": 36.9011,
|
| 32 |
+
"longitude": 50.6558,
|
| 33 |
+
"expected_min_usv": 0.5,
|
| 34 |
+
"category": "natural_high",
|
| 35 |
+
"description": "Ramsar, Iran (high natural radioactivity from radium-rich hot springs)"
|
| 36 |
+
},
|
| 37 |
+
"Guarapari_Beach": {
|
| 38 |
+
"latitude": -20.6714,
|
| 39 |
+
"longitude": -40.4981,
|
| 40 |
+
"expected_min_usv": 0.3,
|
| 41 |
+
"category": "natural_high",
|
| 42 |
+
"description": "Guarapari, Brazil (monazite sand background)"
|
| 43 |
+
},
|
| 44 |
+
"Tokyo_Shinjuku": {
|
| 45 |
+
"latitude": 35.6938,
|
| 46 |
+
"longitude": 139.7034,
|
| 47 |
+
"expected_min_usv": 0.05,
|
| 48 |
+
"category": "background",
|
| 49 |
+
"description": "Tokyo Metropolitan Area"
|
| 50 |
+
},
|
| 51 |
+
"Paris_Eiffel": {
|
| 52 |
+
"latitude": 48.8584,
|
| 53 |
+
"longitude": 2.2945,
|
| 54 |
+
"expected_min_usv": 0.06,
|
| 55 |
+
"category": "background",
|
| 56 |
+
"description": "Paris, France"
|
| 57 |
+
},
|
| 58 |
+
"New_York_Manhattan": {
|
| 59 |
+
"latitude": 40.7831,
|
| 60 |
+
"longitude": -73.9712,
|
| 61 |
+
"expected_min_usv": 0.07,
|
| 62 |
+
"category": "background",
|
| 63 |
+
"description": "New York City, USA"
|
| 64 |
+
},
|
| 65 |
+
"London_Trafalgar": {
|
| 66 |
+
"latitude": 51.508,
|
| 67 |
+
"longitude": -0.1281,
|
| 68 |
+
"expected_min_usv": 0.06,
|
| 69 |
+
"category": "background",
|
| 70 |
+
"description": "London, UK"
|
| 71 |
+
},
|
| 72 |
+
"Denver_High_Altitude": {
|
| 73 |
+
"latitude": 39.7392,
|
| 74 |
+
"longitude": -104.9903,
|
| 75 |
+
"expected_min_usv": 0.12,
|
| 76 |
+
"category": "background_elevated",
|
| 77 |
+
"description": "Denver, Colorado (mile-high altitude cosmic ray contribution)"
|
| 78 |
+
}
|
| 79 |
+
}
|
spatial_ensemble_regressor.joblib
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d892d2b36087e0985d4be51f471beef1d9739a505d284a9739da538dc8c5d8ff
|
| 3 |
+
size 7032362
|
spatial_regressor.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3fddaf53b89b8e12ecdfdc1a0f96071db5507c3e8bcde1bcec0d5821a8af4939
|
| 3 |
+
size 1607085
|