File size: 3,946 Bytes
17bcaed 169ce9d 3fcf064 169ce9d 3fcf064 169ce9d 3fcf064 169ce9d 3fcf064 169ce9d 3fcf064 169ce9d 3fcf064 52be08c 3fcf064 169ce9d 3fcf064 169ce9d 3fcf064 169ce9d 3fcf064 169ce9d 3fcf064 169ce9d 3fcf064 169ce9d 3fcf064 169ce9d 3fcf064 169ce9d 3fcf064 169ce9d 3fcf064 169ce9d 3fcf064 169ce9d 3fcf064 169ce9d 3fcf064 169ce9d 3fcf064 169ce9d 3fcf064 169ce9d 3b77372 17bcaed | 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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | ---
tags:
- llm
- radio_signal
- signal
- audio
- rf
---
# π‘ RF Signal Classification Model
A Transformer-based model for Radio Frequency (RF) signal classification using spectrogram representations of SDR (Software Defined Radio) recordings.
This model leverages Hugging Face Transformers and the ASTForAudioClassification architecture (Audio Spectrogram Transformer β AST) to classify RF signals directly from audio recordings.
## π Model Overview
* Architecture: ASTForAudioClassification
* Input: SDR audio recordings (e.g., .wav, .mp3)
* Feature Extraction: AutoFeatureExtractor
* Framework: Hugging Face Transformers
* Task: RF signal classification
The model expects audio sampled at 16 kHz and processes waveform inputs into spectrogram features internally.
## USAGE EXAMPLE
Example signal: ACARS [zip_file](https://huggingface.co/Neo111x/rf_classifier/blob/main/ACARS_sound.mp3.zip)
<audio controls src="https://cdn-uploads.huggingface.co/production/uploads/64d3db80aea0ccb1b4975d95/tFccUxu_EvCkKY2UQTwgB.mpga"></audio>
```python
from transformers import AutoFeatureExtractor, ASTForAudioClassification
from datasets import Dataset, Audio
import torch
import matplotlib.pyplot as plt
# Load feature extractor and model
feature_extractor = AutoFeatureExtractor.from_pretrained("Neo111x/rf_classifier")
model = ASTForAudioClassification.from_pretrained("Neo111x/rf_classifier")
# Use the path to your SDR record file
data = {"audio": ["./ACARS_sound.mp3"]}
# Create dataset and cast to Audio feature (16kHz expected)
dataset = Dataset.from_dict(data).cast_column("audio", Audio(sampling_rate=16000))
# Decode audio
audio_data = dataset[0]["audio"]
audio_array = audio_data["array"]
sampling_rate = audio_data["sampling_rate"]
# Extract features
inputs = feature_extractor(audio_array, sampling_rate=sampling_rate, return_tensors="pt")
# Run inference
with torch.no_grad():
logits = model(**inputs).logits
predicted_class_ids = torch.argmax(logits, dim=-1).item()
predicted_label = model.config.id2label[predicted_class_ids]
print("Predicted Label:", predicted_label)
# Compute loss (example with target label)
target_label = model.config.id2label[0]
inputs["labels"] = torch.tensor([model.config.label2id[target_label]])
loss = model(**inputs).loss
print("Loss:", round(loss.item(), 2))
# Plot spectrogram (waterfall)
plt.figure(figsize=(12, 6))
plt.specgram(audio_array, NFFT=1024, Fs=sampling_rate, cmap='viridis')
plt.title("SDR Waterfall Plot")
plt.xlabel("Time (s)")
plt.ylabel("Frequency (Hz)")
plt.colorbar(label="Intensity (dB)")
plt.show()
```
## π Input Requirements
* Audio format: .wav, .mp3, or other supported formats
* Sampling rate: 16,000 Hz
* Mono audio preferred
* SDR recordings converted to baseband audio
## π Output
The model outputs:
Predicted label (RF signal class)
Logits for each class
Optional loss value (if labels are provided)
Example output:
```
Predicted Label: ACARS
Loss: 0.12
```

## Supported classes
* 4G LTE Network
* 5G "New Radio" cellular network - Downlink
* Aircraft Communications Addressing and Reporting System (ACARS)
* Amplitude Modulation (AM)
* Automatic Identification System (AIS)
* Automatic Link Set-up (ALIS)
* Automatic Picture Transmission (APT)
* Bluetooth
* Differential Global Positioning System (DGPS)
* Digital Audio Broadcasting Plus (DAB+)
* Digital Mobile Radio (DMR)
* Digital Video Broadcasting β Terrestrial (DVB-T)
* High Frequency Data Link (HFDL)
* Instrument Landing System
* M20 Radiosonde
* Morse Code (CW)
* Non-Directional Beacon (NDB)
* Radar altimeter
* STANAG 5065
* Secondary surveillance radar (SSR)
* Single Sideband Voice
* Tetrapol
* VHF Data Link - Mode 2 (VDL-M2)
* VHF Omnidirectional Range (VOR) |