【开源数据下载全步骤】利用Pytorch下载开源数据到本地,以Speech Command为例

本文介绍了如何通过PyTorch便捷地下载和在本地使用SpeechCommand数据集,这是一个用于语音识别的开源数据集。通过指定数据保存路径、URL、数据子集等参数,可以轻松下载所需版本的数据,并等待下载完成。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

背景

开源数据来练练手,虽然可以直接通过pytorch或TensorFlow加载使用,但感觉太麻烦了,所以想直接下载到本地使用。上网直接搜数据集没有那种直接下载的链接,最后发现可以直接通过pytorch或是TensorFlow下载。下面以pytorch下载Speech Command数据集为例。

下载方法介绍(可直接看最后的下载代码)

1、找到对应数据的页面

Speech Command数据集

 拖到下面的Dataset Loader,根据需要选择对应的下载路径。本例使用pytorch。

 2、找到对应的代码仓

root (str or Path) – 
Path to the directory where the dataset is found or downloaded.

url (str, optional) – 
The URL to download the dataset from, or the type of the dataset to download. 
Allowed type values are "speech_commands_v0.01" and "speech_commands_v0.02" 
(default: "speech_commands_v0.02")

folder_in_archive (str, optional) – 
The top-level directory of the dataset. 
(default: "SpeechCommands")

download (bool, optional) – 
Whether to download the dataset if it is not found at root path. 
(default: False).

subset (str or None, optional) – 
Select a subset of the dataset [None, “training”, “validation”, “testing”]. 
None means the whole dataset. 
“validation” and “testing” are defined in “validation_list.txt” and “testing_list.txt”, respectively, and “training” is the rest. 
Details for the files “validation_list.txt” and “testing_list.txt” are explained in the README of the dataset and in the introduction of Section 7 of the original paper and its reference 12. 
(Default: None)

根据上面所说的调用,即可下载

下载代码

下载数据
from torchaudio import datasets

datasets.SPEECHCOMMANDS(
    root="./data",                         # 你保存数据的路径
    url = 'speech_commands_v0.02',         # 下载数据版本URL
    folder_in_archive = 'SpeechCommands',  
    download = True                        # 这个记得选True 
)

然后就等下载就行了(要等一段时间,不行就科学上网)

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值