Comments (4)
这样,要执行两次,第一次是预热。
def infer():
s = time.time()
data = load_audio(args.audio_path, mode='infer')
data = data[np.newaxis, :]
data = torch.tensor(data, dtype=torch.float32, device=device)
# 执行预测
output = model(data)
result = torch.nn.functional.softmax(output, dim=-1)
result = result.data.cpu().numpy()
# 显示图片并输出结果最大的label
lab = np.argsort(result)[0][-1]
print(f'音频:{args.audio_path} 的预测结果标签为:{class_labels[lab]}')
print(time.time() - s)
from audioclassification-pytorch.
这样,要执行两次,第一次是预热。
def infer(): s = time.time() data = load_audio(args.audio_path, mode='infer') data = data[np.newaxis, :] data = torch.tensor(data, dtype=torch.float32, device=device) # 执行预测 output = model(data) result = torch.nn.functional.softmax(output, dim=-1) result = result.data.cpu().numpy() # 显示图片并输出结果最大的label lab = np.argsort(result)[0][-1] print(f'音频:{args.audio_path} 的预测结果标签为:{class_labels[lab]}') print(time.time() - s)
时间是1.5104613304138184
执行两次是为什么,因为我多次执行基本都是1.5左右,是不是因为启动也需要时间的原因,如果批预测的话平均时间就低了?不知道我的理解对吗,如果看推理速度的话,应该是计算多个文件预测的平均时间吧
from audioclassification-pytorch.
你的预热是再一个程序里面执行多次吗?
是这样的哦:
if __name__ == '__main__':
infer()
infer()
infer()
from audioclassification-pytorch.
你的预热是再一个程序里面执行多次吗? 是这样的哦:
if __name__ == '__main__': infer() infer() infer()
sorry,我明白了,确实是预热的原因,时间是0.031914710998535156,很快了,多谢!
from audioclassification-pytorch.
Related Issues (20)
- 配置文件中的数据预处理参数有问题, feature_method: 'Spectrogram',报错,参数解析有问题 HOT 3
- A same torchaudio warning issued repeatedly in trainning and infering HOT 2
- How to run with features MFCC HOT 2
- Multi-gpu training RuntimeError
- 预训练模型 HOT 1
- 没有 PANNS 模型 HOT 2
- KeyError: 'n_mfcc' HOT 2
- .
- 训练完成后,UrbanSound8K测试集的准确率可以达到多少 HOT 2
- Fixing A Broken Link
- 自选数据集训练报错 HOT 3
- How to detect and classify multiple sound at the same time? HOT 2
- can flac format be used as dataset HOT 3
- RuntimeWarning when train HOT 1
- 如何分类一个10毫秒左右的音频 HOT 3
- 如何提交并发量和减少cpu的资源 HOT 1
- 做歌曲分类的话能有效果吗 HOT 3
- cuda一定要使用11.6吗?安装CUDA 12.1后训练报错 HOT 1
- 训练次数 HOT 10
- 训练自己的数据集 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from audioclassification-pytorch.