|
Download README.md from Neo111x/rf_classifier: direct link, hf CLI and curl.
- Browser
- Download file 3.95 kB
-
https://huggingface.co/Neo111x/rf_classifier/resolve/main/README.md
- Command line
-
hf download hf://Neo111x/rf_classifier/README.md
-
curl -L -o README.md https://huggingface.co/Neo111x/rf_classifier/resolve/main/README.md
3.95 kB
| 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) |