Views
No views yet


1import torch
2import torchaudio
3import torch.nn.functional as F
4from transformers import AutoModel
5
6model = AutoModel.from_pretrained('jiangab/FISHER-tiny-0723', trust_remote_code=True)
7model = model.cuda()
8model.eval()
9
10wav, sr = torchaudio.load('/path/to/local/signal.wav')
11# You can replace it with your custom loading function for other signals
12
13wav = wav - wav.mean()
14STFT = torchaudio.transforms.Spectrogram(
15 n_fft=25 * sr // 1000,
16 win_length=None,
17 hop_length=10 * sr // 1000,
18 power=1,
19 center=False
20)
21spec = torch.log(torch.abs(STFT(wav)) + 1e-10)
22spec = spec.transpose(-2, -1) # [1, time, freq]
23spec = (spec + 3.017344307886898) / (2.1531635155379805 * 2)
24
25# time-wise cutoff
26if spec.shape[-2] > 1024:
27 spec = spec[:, :1024]
28# freq-wise padding
29if spec.shape[-1] < model.cfg.band_width:
30 spec = F.pad(spec, (0, model.cfg.band_width - spec.shape[-1]))
31spec = spec.unsqueeze(1).cuda()
32
33with torch.no_grad():
34 # Use autocast for mixed precision inference. You can disable it for full precision.
35 with torch.autocast('cuda'):
36 repre = model.extract_features(spec)
37print(repre.shape)1@article{fan2025fisher,
2 title={FISHER: A Foundation Model for Multi-Modal Industrial Signal Comprehensive Representation},
3 author={Fan, Pingyi and Jiang, Anbai and Zhang, Shuwei and Lv, Zhiqiang and Han, Bing and Zheng, Xinhu and Liang, Wenrui and Li, Junjie and Zhang, Wei-Qiang and Qian, Yanmin and Chen, Xie and Lu, Cheng and Liu, Jia},
4 journal={arXiv preprint arXiv:2507.16696},
5 year={2025}
6}