mlverse / torchaudio

R interface to torchaudio
https://mlverse.github.io/torchaudio/
Other
27 stars 6 forks source link

I can't load data from an example from a book #69

Open mytarmail opened 1 year ago

mytarmail commented 1 year ago

Hi ! i try to run this dataset but can not https://skeydan.github.io/Deep-Learning-and-Scientific-Computing-with-R-torch/audio_classification.html

library(torch)
 library(torchaudio)
 library(luz)

 ds <- speechcommand_dataset(
   root = "~/.torch-datasets", 
   url = "speech_commands_v0.01",
   download = TRUE
 )

Error in if (!tools::md5sum(destfile) == checksum) runtime_error(glue::glue("MD5 sums are not identical for file: {destfile}.")) : 
  missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In utils::download.file(url = url, destfile = destfile) :
  URL https://storage.googleapis.com/download.tensorflow.org/data/speech_commands_v0.01.tar.gz: cannot open destfile '~/.torch-datasets/speech_commands_v0.01.tar.gz', reason 'No such file or directory'
2: In utils::download.file(url = url, destfile = destfile) :
  download had nonzero exit status
sessionInfo()
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

time zone: Europe/Kiev
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] torchdatasets_0.3.0 torchaudio_0.3.1    luz_0.4.0           torch_0.11.0  
dfalbel commented 1 year ago

Hi @mytarmail

Thanks for reporting, this is a bug in our implementation which fails if the root directory doesn't exist. A workaround is to, create the directory first, and then pass to the root argument.

library(torch)
library(torchaudio)
library(luz)

dir <- fs::dir_create("~/torch-datasets")
ds <- speechcommand_dataset(
  root = dir, 
  url = "speech_commands_v0.01",
  download = TRUE
)