Views
No views yet
Ocean Fingerprint — Full System Architecture. It's designed to train on public
underwater acoustic datasets (DeepShip, ShipsEar) and to simulate "drift" (mechanical
wear) and "spoofing" (identity mismatch) via audio augmentation, since adversarial
recordings of real spoofing attempts don't exist publicly.pip install -r requirements.txttorch, torchaudio, librosa, soundfile,
scikit-learn, numpy, pandas, matplotlib, streamlit..wav files and a metadata/label file (ship class
or vessel ID per file). Then build a manifest CSV:1python src/build_manifest.py --audio_dir /path/to/wavs --labels_csv /path/to/labels.csv \
2 --out data/manifest.csvvessel_id,timestamp,filepath,condition_label,sea_state,depth,speed,ambient_noise_dbbuild_manifest.py can also auto-generate one from
a folder structure like data/raw/<vessel_id>/<clip>.wav — see --infer_from_dirs.1python src/preprocessing.py --manifest data/manifest.csv --out_dir data/features \
2 --window_sec 3.0 --overlap 0.5 --feature mel.npy files, plus an updated manifest
(data/features/windows_manifest.csv) with one row per window.1python src/augment.py --manifest data/features/windows_manifest.csv \
2 --out_dir data/features_augmenteddrift_early, drift_severe, and spoofed by
applying pitch-shift / noise-injection / time-stretch to existing clips, exactly as
described in the architecture doc (section 8).1# Recommended: ECAPA-TDNN backbone + AAM-Softmax (ArcFace-style) loss
2python src/train.py --manifest data/features_augmented/manifest.csv \
3 --epochs 30 --batch_size 32 --embedding_dim 192 \
4 --backbone ecapa_tdnn --loss aam_softmax --out_dir checkpoints/
5
6# Original triplet-loss setup is still available
7python src/train.py --manifest data/features_augmented/manifest.csv \
8 --epochs 30 --batch_size 32 --embedding_dim 192 \
9 --backbone tdnn --loss triplet --out_dir checkpoints/tdnn (x-vector style), resnet_lite, or ecapa_tdnn (SE-Res2Blocks +
multi-layer feature aggregation + attentive statistics pooling — current standard
architecture for speaker/acoustic verification, recommended default).triplet (original) or aam_softmax (angular-margin classification loss,
recommended — trains faster and produces a more separated embedding space; see
src/losses.py docstring). aam_softmax also applies SpecAugment automatically
(src/augment.py::spec_augment, disable with --no_spec_augment). Both loss modes
support mixed-precision training on CUDA via --amp (on by default).src/model.py, src/dataset.py, src/losses.py.config.yaml's drift_threshold / identity_threshold are starting points, not
tuned values. Once you have a trained checkpoint and a held-out manifest (vessels
or time windows not used in training/enrollment), calibrate them properly from an
EER (Equal Error Rate) analysis instead of guessing:1python src/calibrate_thresholds.py --manifest data/holdout/manifest.csv \
2 --checkpoint checkpoints/best.pt --condition baseline \
3 --update_config config.yamldrift_threshold / identity_threshold back
into config.yaml. See src/calibrate_thresholds.py docstring for the methodology.1python src/enroll.py --manifest data/features_augmented/manifest.csv \
2 --checkpoint checkpoints/best.pt --condition baseline --out data/fingerprint_db.jsonsrc/fingerprint_db.py).1python src/comparison_engine.py --checkpoint checkpoints/best.pt \
2 --db data/fingerprint_db.json --clip /path/to/new_clip.wav --claimed_vessel INS_0001normal, drift, mismatch.src/drift_detection.py maintains embedding_history[vessel_id] and runs an
Isolation Forest / rolling control chart over the distance-from-baseline series to
distinguish sudden jumps (likely damage/event) from slow steady drift (maintenance
scheduling signal).streamlit run dashboard/app.pydata/fingerprint_db.json and data/alert_log.csv.ocean_fingerprint/
├── README.md
├── requirements.txt
├── config.yaml
├── data/ # you populate this
├── checkpoints/ # trained models land here
├── src/
│ ├── build_manifest.py
│ ├── preprocessing.py # denoise, segment, mel/CQT features
│ ├── augment.py # drift + spoof simulation
│ ├── dataset.py # triplet + classification-style PyTorch Datasets
│ ├── calibrate_thresholds.py # EER-based drift/identity threshold calibration
│ ├── model.py # TDNN/ResNet-lite embedding network
│ ├── losses.py # triplet / contrastive / AAM-Softmax (ArcFace) loss
│ ├── train.py # training loop
│ ├── fingerprint_db.py # enrollment DB (JSON-backed)
│ ├── enroll.py # CLI to build the DB
│ ├── comparison_engine.py # inference: distance + thresholds
│ ├── drift_detection.py # Isolation Forest / control chart over embedding history
│ └── utils.py
└── dashboard/
└── app.py # Streamlit dashboardenvironmental_metadata
fields exist so you can eventually condition the model on them or hold them out as a
robustness test — this codebase logs them but does not yet fully solve the confound.
Expect to spend real iteration time here.augment.py
simulation is a stand-in, clearly labeled as such).