Wonder-Griffin/TorNet-Oracle
011
1---2library_name: pytorch3license: mit4datasets:5- TorNet6tags:7- weather8- radar9- tornado10- tornado_prediction11- NEXRAD12- MRMS13- HRRR14- lightning15metrics:16- auprc17- f118- accuracy19- brier20- ece21pipeline_tag: image-classification22language:23- en24---25 26# Wonder-Griffin/tornado-super-predictor27 28**TornadoSuperPredictor** from Storm-Oracle, trained on **TorNet (Zenodo)** patches. 29Outputs a tornado probability per patch (optionally with atmospheric features).30 31## Summary32 33- **Data**: TorNet (official split); optional recent holdout recommended. 34- **Architecture**: CNN feature extractor + heads (probability, EF logits, location, timing, uncertainty). 35- **Temporal**: 3 volume(s) stacked as channels. 36- **Normalization**: zscore. 37- **Loss**: bce (pos_weight=2.0). 38- **Calibration**: Platt (A,B)=n/a,n/a; Temperature T=n/a.39 40## Intended Use41 42- Research on tornado nowcasting from radar patches; 43- Evaluation under class imbalance with PR metrics; 44- **Not** an operational warning system without further validation & human oversight.45 46## Dataset47 48- **Train examples**: 6 49- **Eval examples**: 4 50- **Class balance**: positives=n/a, negatives=n/a, pos_weight≈2.051 52## Evaluation (threshold = 0.5)53 54Confusion matrix (rows = truth, cols = prediction):55 56| | Pred 0 | Pred 1 |57|-------:|-------:|-------:|58| True 0 | 0 | 2 |59| True 1 | 0 | 2 |60 61Metrics:62 63- **AUPRC**: n/a 64- **Accuracy**: n/a 65- **(Optional)**: attach PR curve & reliability diagrams66 67## Training68 69- Optimizer: AdamW (lr=1e-4, wd=1e-4 by default) 70- Batch size: n/a 71- Epochs: n/a 72- Precision: 16-mixed 73- Augmentations: flips/rotations/intensity jitter + optional crops 74- Hardware: 1× GPU (FP16 mixed)75 76## Quickstart77 78```python79import torch80from transformers import AutoModel81 82repo = "Wonder-Griffin/TorNet-Oracle"83model = AutoModel.from_pretrained(repo, trust_remote_code=True).eval()84 85# Example dummy batch86B, T, H, W = 2, 1, 256, 256 # T time steps -> in_channels = 3*T (reflectivity, velocity, spectrum width?)87radar_x = torch.randn(B, 3*T, H, W)88 89# Atmospheric dictionary (use only what you have; shapes must be (B, dim))90atmo = {91 "cape": torch.randn(B, 1),92 "wind_shear": torch.randn(B, 4), # 0–1, 0–3, 0–6, deep93 "helicity": torch.randn(B, 2), # 0–1, 0–394 "temperature": torch.randn(B, 3), # sfc, 850, 50095 "dewpoint": torch.randn(B, 2), # sfc, 85096 "pressure": torch.randn(B, 1),97}98 99out = model(radar_x=radar_x, atmo=atmo)100print(out.tornado_probability.shape) # (B,)101print(out.ef_scale_probs.shape) # (B, 6)102print(out.location_offset.shape) # (B, 2)103print(out.timing_predictions.shape) # (B, 3)104---105 106# 3) Notes to avoid common gotchas107 108- **Export the class names**: Make sure `StormOracleModel` and `StormOracleConfig` are importable at the repo root via `__init__.py`. Hugging Face uses that when `trust_remote_code=True`.109- **Architectures**: The `"architectures"` array in `config.json` **must** include `"StormOracleModel"`.110- **Weights**: You already have `pytorch_model.bin`/**or** `model.safetensors`. Either is fine. Keep the filenames standard.111- **Forward signature**: With remote code, it’s okay that `forward` takes `radar_x` and `atmo`. Users pass them as keyword args as shown.112- **Version pins**: If you rely on features from newer `transformers`, keep the `transformers_version` in `config.json` current.113 114---115 116# 4) Optional niceties117 118- **`hubconf.py`** (for `torch.hub` users):119 ```python120 from .tornado_predictor import TornadoSuperPredictor121 122 def storm_oracle(in_channels=3, pretrained=False, hf_repo=None, map_location="cpu"):123 model = TornadoSuperPredictor(in_channels=in_channels)124 if pretrained and hf_repo is not None:125 from huggingface_hub import hf_hub_download126 path = hf_hub_download(hf_repo, filename="pytorch_model.bin")127 import torch128 state = torch.load(path, map_location=map_location)129 model.load_state_dict(state, strict=True)130 return model