Views
No views yet

StandardScalerd_model)d_state)[batch_size, 181, 1][batch_size, 10]1import torch
2import joblib
3import numpy as np
4from model_code import DroneMambaClassifier
5
6# 1. Load model and preprocessing
7model = DroneMambaClassifier(num_classes=10, d_model=256, depth=6)
8model.load_state_dict(torch.load("pytorch_model.bin", map_location='cpu'))
9scaler = joblib.load("scaler.pkl")
10model.eval()
11
12# 2. Prepare your RCS data (181 points from 0° to 180°)
13rcs_signal = np.random.randn(181, 1) # Replace with your actual RCS measurements
14
15# 3. Normalize and predict
16normalized = scaler.transform(rcs_signal)
17x = torch.tensor(normalized, dtype=torch.float32).unsqueeze(0)
18
19with torch.no_grad():
20 logits = model(x)
21 probs = torch.softmax(logits, dim=1)
22 pred_class = logits.argmax(dim=1).item()
23 confidence = probs[0, pred_class].item()
24
25print(f"Predicted Class: {pred_class}")
26print(f"Confidence: {confidence*100:.2f}%")1# For multiple sequences
2rcs_batch = np.random.randn(10, 181, 1) # 10 sequences
3normalized_batch = scaler.transform(rcs_batch.reshape(-1, 181)).reshape(10, 181, 1)
4x_batch = torch.tensor(normalized_batch, dtype=torch.float32)
5
6with torch.no_grad():
7 predictions = model(x_batch).argmax(dim=1)
8
9print(predictions) # Tensor of predicted classes| File | Description |
|---|---|
pytorch_model.bin | Model weights (state_dict) |
scaler.pkl | StandardScaler fitted on training data |
model_code.py | Model architecture definition |
confusion_matrix.png | Test set confusion matrix visualization |
classification_report.txt | Detailed per-class metrics |
per_class_metrics.csv | Per-class accuracy table |
h'(t) = Ah(t) + Bx(t)Δt computed per tokenB, C, Δt are input-dependent1# Export to ONNX for production deployment
2dummy_input = torch.randn(1, 181, 1)
3torch.onnx.export(
4 model,
5 dummy_input,
6 "dronemamba.onnx",
7 input_names=['rcs_signal'],
8 output_names=['class_logits'],
9 dynamic_axes={'rcs_signal': {0: 'batch'}, 'class_logits': {0: 'batch'}}
10)1@model{dronemamba2024,
2 title={DroneMamba-RCS: Selective State Space Model for Drone Classification},
3 author={Bombek1},
4 year={2024},
5 url={https://huggingface.co/Bombek1/DroneMamba-RCS}
6}
7
8@dataset{drone_rcs_2024,
9 title={Drone RCS Measurement Dataset},
10 author={Goorm-AI-04},
11 year={2024},
12 url={https://huggingface.co/datasets/Goorm-AI-04/Drone_RCS_Measurement}
13}