Downloads · 30 days
0
liduojia/MeanFlowSE
MeanFlowSE is a machine learning model from liduojia. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
<div align="center" <p align="center" <h1MeanFlowSE — One-Step Generative Speech Enhancement</h1
Downloads · 30 days
0
Access
Public
Updated Oct 3, 2025
Repo size
1.3 GB
Likes
1
Public
Click a slice to open those files.
.ckpt1.3 GB · 100%
From the Hugging Face model README
MeanFlowSE is a conditional generative approach to speech enhancement that learns average velocities over short time spans and performs enhancement in a single step. Instead of rolling out a long ODE trajectory, it applies one backward-in-time displacement directly in the complex STFT domain, delivering competitive quality at a fraction of the compute and latency. The model is trained end-to-end with a local JVP-based objective and remains consistent with conditional flow matching on the diagonal—no teacher models, schedulers, or distillation required. In practice, 1-NFE inference makes real-time deployment on standard hardware straightforward.
# Python 3.10 recommended
pip install -r requirements.txt
# Use a recent PyTorch + CUDA build for multi-GPU training
Expected layout:
<BASE_DIR>/
train/clean/*.wav train/noisy/*.wav
valid/clean/*.wav valid/noisy/*.wav
test/clean/*.wav test/noisy/*.wav
Defaults assume 16 kHz audio, centered frames, Hann windows, and a complex STFT representation (see SpecsDataModule for knobs).
Single machine, multi-GPU (DDP):
# Edit DATA_DIR and GPUs inside the script if needed
bash train_vbd.sh
Or run directly:
torchrun --standalone --nproc_per_node=4 train.py \
--backbone ncsnpp \
--ode flowmatching \
--base_dir <BASE_DIR> \
--batch_size 2 \
--num_workers 8 \
--max_epochs 150 \
--precision 32 \
--gradient_clip_val 1.0 \
--t_eps 0.03 --T_rev 1.0 \
--sigma_min 0.0 --sigma_max 0.487 \
--use_mfse \
--mf_weight_final 0.25 \
--mf_warmup_frac 0.5 \
--mf_delta_gamma_start 8.0 --mf_delta_gamma_end 1.0 \
--mf_delta_warmup_frac 0.7 \
--mf_r_equals_t_prob 0.1 \
--mf_jvp_clip 5.0 --mf_jvp_eps 1e-3 \
--mf_jvp_impl fd --mf_jvp_chunk 1 \
--mf_skip_weight_thresh 0.05 \
--val_metrics_every_n_epochs 1 \
--default_root_dir lightning_logs
lightning_logs/<exp_name>/version_x/.Use the helper script:
# MODE = multistep | multistep_mf | onestep
MODE=onestep STEPS=1 \
TEST_DATA_DIR=<BASE_DIR> \
CKPT_INPUT=path/to/best.ckpt \
bash run_inference.sh
Or call the evaluator:
python evaluate.py \
--test_dir <BASE_DIR> \
--folder_destination /path/to/output \
--ckpt path/to/best.ckpt \
--odesolver euler_mf \
--reverse_starting_point 1.0 \
--last_eval_point 0.0 \
--one_step
evaluate.pywrites enhanced WAVs. If--odesolveris not given, it auto-picks (euler_mfwhen MF-SE was used; otherwiseeuler).
Common flags you may want to tweak:
Time & schedule
--T_rev (reverse start, default 1.0), --t_eps (terminal time), --sigma_min, --sigma_maxMF-SE stability
--mf_jvp_impl {auto,fd,autograd}, --mf_jvp_chunk, --mf_jvp_clip, --mf_jvp_eps--mf_weight_final, --mf_warmup_frac, --mf_delta_*, --mf_r_equals_t_probValidation cost
--val_metrics_every_n_epochs, --num_eval_filesBackbone & front-end
backbones/ and SpecsDataModule (STFT, transforms, normalization)MeanFlowSE/
├── train.py # Lightning entry
├── evaluate.py # Enhancement script (WAV out)
├── run_inference.sh # One-step / few-step convenience runner
├── flowmse/
│ ├── model.py # Losses, JVP, curriculum, logging
│ ├── odes.py # Path definition & registry
│ ├── sampling/
│ │ ├── __init__.py
│ │ └── odesolvers.py # Euler (instantaneous) & Euler-MF (displacement)
│ ├── backbones/
│ │ ├── ncsnpp.py # U-Net w/ time & delta embeddings
│ │ └── ...
│ ├── data_module.py # STFT I/O pipeline
│ └── util/ # metrics, registry, tensors, inference helpers
├── requirements.txt
└── scripts/
└── train_vbd.sh
This repository builds upon previous great works:
Many design choices (complex STFT pipeline, training infrastructure) are inspired by these excellent projects.
We gratefully acknowledge Prof. Xie Chen’s group (X-LANCE Lab, SJTU) for their valuable guidance and support on training practices and engineering tips that helped this work a lot.
Questions or issues? Please open a GitHub issue or pull request. We welcome contributions — from bug fixes to new backbones and front-ends.