Image Classification
timm
English
gravitational-waves
ligo
vision-transformer
glitch-classification
gravity-spy
physics
deep-learning
spectrograms
continuous-gravitational-waves
resnet
detector-characterization
Eval Results (legacy)
Instructions to use JesseWeigel/ligo-glitch-vit-cnn with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- timm
How to use JesseWeigel/ligo-glitch-vit-cnn with timm:
import timm model = timm.create_model("hf_hub:JesseWeigel/ligo-glitch-vit-cnn", pretrained=True) - Notebooks
- Google Colab
- Kaggle
Add model card with HuggingFace metadata, tags, and benchmarks
Browse files
README.md
CHANGED
|
@@ -1,9 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# Gravity Spy Glitch Classifier: ViT-B/16 and ResNet-50v2 BiT
|
| 2 |
|
| 3 |
Two deep learning models for classifying LIGO gravitational-wave detector
|
| 4 |
glitch morphologies from Q-transform spectrograms, trained on Gravity Spy O3
|
| 5 |
data (Zevin et al. 2017, CQG 34 064003).
|
| 6 |
|
|
|
|
|
|
|
|
|
|
| 7 |
## Model Overview
|
| 8 |
|
| 9 |
| Property | ViT-B/16 | ResNet-50v2 BiT |
|
|
@@ -17,11 +82,15 @@ Both models classify 224x224 RGB Q-transform spectrograms into 23 Gravity Spy
|
|
| 17 |
glitch classes (22 glitch morphologies + No_Glitch). The class taxonomy follows
|
| 18 |
Zevin et al. (2017).
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
## Training Data
|
| 21 |
|
| 22 |
- **Source:** Gravity Spy O3 (H1 + L1), filtered to ml_confidence > 0.9
|
| 23 |
- **Total samples:** 227,943 training / 48,844 validation / 48,845 test
|
| 24 |
-
- **Split:** Temporal split (70/15/15%) with 60-second gap enforcement
|
| 25 |
- **Classes:** 23 (see `src/class_labels.json`)
|
| 26 |
- **Preprocessing:** Q-transform spectrograms resized to 224x224, normalized with ImageNet statistics
|
| 27 |
- **Rare classes:** Chirp (11 train), Wandering_Line (30), Helix (33), Light_Modulation (142)
|
|
@@ -45,22 +114,15 @@ statistically significant (p = 0.0002).*
|
|
| 45 |
|
| 46 |
### Per-Class Highlights
|
| 47 |
|
| 48 |
-
Architecture preference is **class-morphology-dependent**, not a uniform
|
| 49 |
-
advantage for either model:
|
| 50 |
-
|
| 51 |
| Class | ViT F1 | CNN F1 | Difference | Favors |
|
| 52 |
|---|---|---|---|---|
|
| 53 |
| Power_Line | 0.742 | 0.235 | **+0.507** | ViT |
|
| 54 |
-
| Light_Modulation | 0.859 | 0.691 | +0.168 | ViT |
|
| 55 |
-
| Scratchy | 0.875 | 0.503 | +0.372 | ViT |
|
| 56 |
-
| Chirp | 0.000 | 0.471 | **+0.471** | CNN |
|
| 57 |
-
| Scattered_Light | 0.719 | 0.811 | +0.092 | CNN |
|
| 58 |
| Paired_Doves | 0.613 | 0.099 | +0.514 | ViT |
|
| 59 |
-
|
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
|
| 65 |
## O4 Generalization
|
| 66 |
|
|
@@ -69,40 +131,32 @@ Both models were evaluated on 38,587 O4a Gravity Spy spectrograms:
|
|
| 69 |
| Metric | ViT-B/16 | ResNet-50v2 BiT |
|
| 70 |
|---|---|---|
|
| 71 |
| O4 macro-F1 | 0.6695 [0.6555, 0.6816] | 0.6674 [0.6567, 0.6765] |
|
| 72 |
-
| Relative degradation from O3 |
|
| 73 |
|
| 74 |
-
Both models pass the <20% degradation threshold.
|
| 75 |
-
generalization stability across observing runs.
|
| 76 |
|
| 77 |
## Limitations
|
| 78 |
|
| 79 |
-
- **O3-trained only:**
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
- **
|
| 83 |
-
|
| 84 |
-
- **
|
| 85 |
-
misclassified into existing categories.
|
| 86 |
-
- **Rare-class regression for ViT:** The ViT's macro-F1 advantage does not
|
| 87 |
-
extend to rare classes (< 200 training samples). The CNN outperforms on
|
| 88 |
-
Chirp, Helix, and Violin_Mode.
|
| 89 |
-
- **Label quality:** Training labels are from ml_confidence > 0.9 filtering
|
| 90 |
-
of Gravity Spy citizen science classifications, not expert-reviewed labels.
|
| 91 |
|
| 92 |
## Usage
|
| 93 |
|
| 94 |
```bash
|
| 95 |
-
# Install dependencies
|
| 96 |
pip install torch timm albumentations numpy Pillow
|
| 97 |
|
| 98 |
# Classify a spectrogram with ViT
|
| 99 |
-
python
|
| 100 |
|
| 101 |
# Classify with CNN, showing top-5 predictions
|
| 102 |
-
python
|
| 103 |
|
| 104 |
# JSON output
|
| 105 |
-
python
|
| 106 |
```
|
| 107 |
|
| 108 |
### Input Format
|
|
@@ -111,63 +165,41 @@ python release/src/inference.py --model vit --image path/to/spectrogram.png --js
|
|
| 111 |
- Any resolution (automatically resized to 224x224)
|
| 112 |
- RGB color (grayscale images are converted to 3-channel)
|
| 113 |
|
| 114 |
-
### Output
|
| 115 |
-
|
| 116 |
-
```
|
| 117 |
-
Model: ViT-B/16
|
| 118 |
-
Image: spectrogram.png
|
| 119 |
-
|
| 120 |
-
Predictions:
|
| 121 |
-
Rank Class Probability
|
| 122 |
-
-------------------------------------------
|
| 123 |
-
1 Blip 0.9823
|
| 124 |
-
2 Blip_Low_Frequency 0.0091
|
| 125 |
-
3 Koi_Fish 0.0034
|
| 126 |
-
```
|
| 127 |
-
|
| 128 |
## File Structure
|
| 129 |
|
| 130 |
```
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
examples/
|
| 143 |
-
expected_output.json # Validated predictions for test images
|
| 144 |
-
```
|
| 145 |
-
|
| 146 |
-
## Verifying Checkpoint Integrity
|
| 147 |
-
|
| 148 |
-
```bash
|
| 149 |
-
cd release/checkpoints
|
| 150 |
-
sha256sum -c checksums.sha256
|
| 151 |
```
|
| 152 |
|
| 153 |
## Citation
|
| 154 |
|
| 155 |
```bibtex
|
| 156 |
-
@
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
|
|
|
| 162 |
}
|
| 163 |
```
|
| 164 |
|
| 165 |
## License
|
| 166 |
|
| 167 |
-
|
| 168 |
|
| 169 |
## References
|
| 170 |
|
| 171 |
-
- Zevin, M. et al. (2017). "Gravity Spy: integrating advanced LIGO detector
|
| 172 |
-
|
| 173 |
-
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: cc-by-4.0
|
| 4 |
+
library_name: timm
|
| 5 |
+
tags:
|
| 6 |
+
- gravitational-waves
|
| 7 |
+
- ligo
|
| 8 |
+
- vision-transformer
|
| 9 |
+
- image-classification
|
| 10 |
+
- glitch-classification
|
| 11 |
+
- gravity-spy
|
| 12 |
+
- physics
|
| 13 |
+
- deep-learning
|
| 14 |
+
- spectrograms
|
| 15 |
+
- continuous-gravitational-waves
|
| 16 |
+
- resnet
|
| 17 |
+
- detector-characterization
|
| 18 |
+
datasets:
|
| 19 |
+
- custom
|
| 20 |
+
metrics:
|
| 21 |
+
- f1
|
| 22 |
+
- accuracy
|
| 23 |
+
pipeline_tag: image-classification
|
| 24 |
+
model-index:
|
| 25 |
+
- name: ViT-B/16 Gravity Spy Glitch Classifier
|
| 26 |
+
results:
|
| 27 |
+
- task:
|
| 28 |
+
type: image-classification
|
| 29 |
+
name: Image Classification
|
| 30 |
+
dataset:
|
| 31 |
+
name: Gravity Spy O3 (temporal split)
|
| 32 |
+
type: custom
|
| 33 |
+
metrics:
|
| 34 |
+
- name: Macro-F1
|
| 35 |
+
type: f1
|
| 36 |
+
value: 0.723
|
| 37 |
+
- name: Accuracy
|
| 38 |
+
type: accuracy
|
| 39 |
+
value: 0.934
|
| 40 |
+
- name: Rare-class Macro-F1
|
| 41 |
+
type: f1
|
| 42 |
+
value: 0.241
|
| 43 |
+
- name: ResNet-50v2 BiT Gravity Spy Glitch Classifier
|
| 44 |
+
results:
|
| 45 |
+
- task:
|
| 46 |
+
type: image-classification
|
| 47 |
+
name: Image Classification
|
| 48 |
+
dataset:
|
| 49 |
+
name: Gravity Spy O3 (temporal split)
|
| 50 |
+
type: custom
|
| 51 |
+
metrics:
|
| 52 |
+
- name: Macro-F1
|
| 53 |
+
type: f1
|
| 54 |
+
value: 0.679
|
| 55 |
+
- name: Accuracy
|
| 56 |
+
type: accuracy
|
| 57 |
+
value: 0.918
|
| 58 |
+
- name: Rare-class Macro-F1
|
| 59 |
+
type: f1
|
| 60 |
+
value: 0.303
|
| 61 |
+
---
|
| 62 |
+
|
| 63 |
# Gravity Spy Glitch Classifier: ViT-B/16 and ResNet-50v2 BiT
|
| 64 |
|
| 65 |
Two deep learning models for classifying LIGO gravitational-wave detector
|
| 66 |
glitch morphologies from Q-transform spectrograms, trained on Gravity Spy O3
|
| 67 |
data (Zevin et al. 2017, CQG 34 064003).
|
| 68 |
|
| 69 |
+
**Paper**: Manuscript submitted to Classical and Quantum Gravity
|
| 70 |
+
**Code**: [GitHub](https://github.com/JesseRWeigel/ligo-glitch-vit-cnn)
|
| 71 |
+
|
| 72 |
## Model Overview
|
| 73 |
|
| 74 |
| Property | ViT-B/16 | ResNet-50v2 BiT |
|
|
|
|
| 82 |
glitch classes (22 glitch morphologies + No_Glitch). The class taxonomy follows
|
| 83 |
Zevin et al. (2017).
|
| 84 |
|
| 85 |
+
## Key Finding
|
| 86 |
+
|
| 87 |
+
Architecture preference is **class-dependent**: ViT excels on spectrally distinctive classes (Power_Line: +0.507 F1) but shows insufficient evidence of improvement on rare classes (< 200 training samples). Neither architecture uniformly dominates.
|
| 88 |
+
|
| 89 |
## Training Data
|
| 90 |
|
| 91 |
- **Source:** Gravity Spy O3 (H1 + L1), filtered to ml_confidence > 0.9
|
| 92 |
- **Total samples:** 227,943 training / 48,844 validation / 48,845 test
|
| 93 |
+
- **Split:** Temporal split (70/15/15%) with 60-second gap enforcement (prevents data leakage)
|
| 94 |
- **Classes:** 23 (see `src/class_labels.json`)
|
| 95 |
- **Preprocessing:** Q-transform spectrograms resized to 224x224, normalized with ImageNet statistics
|
| 96 |
- **Rare classes:** Chirp (11 train), Wandering_Line (30), Helix (33), Light_Modulation (142)
|
|
|
|
| 114 |
|
| 115 |
### Per-Class Highlights
|
| 116 |
|
|
|
|
|
|
|
|
|
|
| 117 |
| Class | ViT F1 | CNN F1 | Difference | Favors |
|
| 118 |
|---|---|---|---|---|
|
| 119 |
| Power_Line | 0.742 | 0.235 | **+0.507** | ViT |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
| Paired_Doves | 0.613 | 0.099 | +0.514 | ViT |
|
| 121 |
+
| Scratchy | 0.875 | 0.503 | +0.372 | ViT |
|
| 122 |
+
| Light_Modulation | 0.859 | 0.691 | +0.168 | ViT |
|
| 123 |
+
| Chirp | 0.000 | 0.471 | **−0.471** | CNN |
|
| 124 |
+
| Violin_Mode | 0.544 | 0.683 | −0.139 | CNN |
|
| 125 |
+
| Scattered_Light | 0.719 | 0.811 | −0.092 | CNN |
|
| 126 |
|
| 127 |
## O4 Generalization
|
| 128 |
|
|
|
|
| 131 |
| Metric | ViT-B/16 | ResNet-50v2 BiT |
|
| 132 |
|---|---|---|
|
| 133 |
| O4 macro-F1 | 0.6695 [0.6555, 0.6816] | 0.6674 [0.6567, 0.6765] |
|
| 134 |
+
| Relative degradation from O3 | −7.4% | −1.7% |
|
| 135 |
|
| 136 |
+
Both models pass the <20% degradation threshold.
|
|
|
|
| 137 |
|
| 138 |
## Limitations
|
| 139 |
|
| 140 |
+
- **O3-trained only:** Not fine-tuned on O4 data. Performance may degrade on later observing runs.
|
| 141 |
+
- **Single-view:** Uses only the 1.0-second duration Q-transform view (Gravity Spy uses four).
|
| 142 |
+
- **23 classes:** New glitch morphologies in O4+ will be misclassified into existing categories.
|
| 143 |
+
- **Rare-class:** ViT's macro-F1 advantage does not extend to rare classes (< 200 training samples). The rare-class comparison is statistically underpowered (aggregate power = 0.20).
|
| 144 |
+
- **Single seed:** Results from one training run per architecture. No seed variance reported.
|
| 145 |
+
- **Label quality:** Training labels from ml_confidence > 0.9 filtering of Gravity Spy citizen science classifications.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
## Usage
|
| 148 |
|
| 149 |
```bash
|
|
|
|
| 150 |
pip install torch timm albumentations numpy Pillow
|
| 151 |
|
| 152 |
# Classify a spectrogram with ViT
|
| 153 |
+
python src/inference.py --model vit --image path/to/spectrogram.png
|
| 154 |
|
| 155 |
# Classify with CNN, showing top-5 predictions
|
| 156 |
+
python src/inference.py --model cnn --image path/to/spectrogram.png --top-k 5
|
| 157 |
|
| 158 |
# JSON output
|
| 159 |
+
python src/inference.py --model vit --image path/to/spectrogram.png --json
|
| 160 |
```
|
| 161 |
|
| 162 |
### Input Format
|
|
|
|
| 165 |
- Any resolution (automatically resized to 224x224)
|
| 166 |
- RGB color (grayscale images are converted to 3-channel)
|
| 167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
## File Structure
|
| 169 |
|
| 170 |
```
|
| 171 |
+
checkpoints/
|
| 172 |
+
vit_b16_gravityspy_o3.pt # ViT-B/16 weights (~983 MB)
|
| 173 |
+
resnet50v2_gravityspy_o3.pt # ResNet-50v2 BiT weights (~270 MB)
|
| 174 |
+
checksums.sha256 # SHA-256 checksums
|
| 175 |
+
src/
|
| 176 |
+
inference.py # Standalone CLI inference script
|
| 177 |
+
preprocessing.py # Locked evaluation transforms
|
| 178 |
+
class_labels.json # 23-class index-to-label mapping
|
| 179 |
+
model_config.json # Architecture and training config
|
| 180 |
+
examples/
|
| 181 |
+
expected_output.json # Validated predictions for test images
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
```
|
| 183 |
|
| 184 |
## Citation
|
| 185 |
|
| 186 |
```bibtex
|
| 187 |
+
@article{weigel2026vit_glitch,
|
| 188 |
+
author = {Weigel, Jesse R.},
|
| 189 |
+
title = {Vision Transformer vs.\ CNN for Gravitational Wave Glitch Classification:
|
| 190 |
+
Class-Dependent Architecture Preferences and Implications for
|
| 191 |
+
Continuous Wave Searches},
|
| 192 |
+
year = {2026},
|
| 193 |
+
note = {Manuscript submitted to Classical and Quantum Gravity}
|
| 194 |
}
|
| 195 |
```
|
| 196 |
|
| 197 |
## License
|
| 198 |
|
| 199 |
+
CC BY 4.0
|
| 200 |
|
| 201 |
## References
|
| 202 |
|
| 203 |
+
- Zevin, M. et al. (2017). "Gravity Spy: integrating advanced LIGO detector characterization, machine learning, and citizen science." *Classical and Quantum Gravity*, 34(6), 064003.
|
| 204 |
+
- Wu, Z. et al. (2025). "Multi-view Attention Fusion for Gravitational Wave Glitch Classification." *Classical and Quantum Gravity*, 42, 165015.
|
| 205 |
+
- Srivastava, A. and Niedzielski, T. (2025). "Vision Transformer for Transient Noise Classification in Gravitational Wave Data." *Acta Astronomica*, 74(3).
|