Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -12,4 +12,91 @@ license: mit
|
|
| 12 |
short_description: Respiratory monitoring model
|
| 13 |
---
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 12 |
short_description: Respiratory monitoring model
|
| 13 |
---
|
| 14 |
|
| 15 |
+
|
| 16 |
+
# SpeFormer Pipeline
|
| 17 |
+
|
| 18 |
+
This repository includes a respiratory audio separation pipeline built around a local SepFormer model and a clinical reasoning/GNN inference path.
|
| 19 |
+
|
| 20 |
+
## Key Files
|
| 21 |
+
|
| 22 |
+
### model.py
|
| 23 |
+
|
| 24 |
+
Loads the SepFormer separation model using local pretrained files in `pretrained_sepformer`.
|
| 25 |
+
|
| 26 |
+
Wraps encoder/masknet/decoder into `UnifiedSepFormer`.
|
| 27 |
+
|
| 28 |
+
### interface.py
|
| 29 |
+
|
| 30 |
+
Provides shared audio loading, separation, and saving helpers.
|
| 31 |
+
|
| 32 |
+
Includes:
|
| 33 |
+
|
| 34 |
+
* `separate_audio_file(...)`
|
| 35 |
+
* `predict_sources(...)`
|
| 36 |
+
* `save_separated_sources(...)`
|
| 37 |
+
|
| 38 |
+
for pipeline reuse.
|
| 39 |
+
|
| 40 |
+
Still supports the existing Gradio UI workflow via:
|
| 41 |
+
|
| 42 |
+
* `separate_audio(...)`
|
| 43 |
+
|
| 44 |
+
### pipeline.py
|
| 45 |
+
|
| 46 |
+
Runs separation over a directory of mixture audio files.
|
| 47 |
+
|
| 48 |
+
Writes separated WAVs and waveform PNGs to an output folder.
|
| 49 |
+
|
| 50 |
+
Produces:
|
| 51 |
+
|
| 52 |
+
* `pipeline_summary.json`
|
| 53 |
+
* `pipeline_summary.csv`
|
| 54 |
+
|
| 55 |
+
### gnn.py
|
| 56 |
+
|
| 57 |
+
Defines the GNN model architecture used for respiratory audio reasoning.
|
| 58 |
+
|
| 59 |
+
Provides utilities for:
|
| 60 |
+
|
| 61 |
+
* loading a GNN checkpoint
|
| 62 |
+
* estimating breathing rate
|
| 63 |
+
* patient state tracking
|
| 64 |
+
* clinical alert generation
|
| 65 |
+
|
| 66 |
+
### reasoning_pipeline.py
|
| 67 |
+
|
| 68 |
+
Processes GNN run outputs:
|
| 69 |
+
|
| 70 |
+
* `window_report.json`
|
| 71 |
+
* `window_report.csv`
|
| 72 |
+
|
| 73 |
+
Generates reasoning summary CSV/JSON files.
|
| 74 |
+
|
| 75 |
+
Includes visualization helpers for per-patient summary plots.
|
| 76 |
+
|
| 77 |
+
### full_pipeline.py
|
| 78 |
+
|
| 79 |
+
Runs the complete flow:
|
| 80 |
+
|
| 81 |
+
1. Separate mixture audio files
|
| 82 |
+
2. Run Wav2Vec2 + GNN inference
|
| 83 |
+
3. Save per-run artifacts
|
| 84 |
+
4. Aggregate reasoning summaries
|
| 85 |
+
|
| 86 |
+
## Running a Simulation
|
| 87 |
+
To test the system using the provided sample data:
|
| 88 |
+
|
| 89 |
+
1. Open the Patient Registration page.
|
| 90 |
+
2. Navigate to the Sample_Audio folder.
|
| 91 |
+
3. Upload S1, S2, and S3 as individual patient recordings.
|
| 92 |
+
4. Click Register to register each patient.
|
| 93 |
+
|
| 94 |
+
Next:
|
| 95 |
+
|
| 96 |
+
1. Open the Separation page.
|
| 97 |
+
2. Upload Sample_0_mix.wav from the Sample_Audio folder as the mixed audio recording.
|
| 98 |
+
3. Select the registered patients (S1, S2, and S3).
|
| 99 |
+
4. Click Run Separation.
|
| 100 |
+
|
| 101 |
+
|
| 102 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|