I am trying to access MNIST images from MNIST handwritten digit database, Yann LeCun, Corinna Cortes and Chris Burges.
This works, but it looks a bit cumbersome.
Is there a better way? Perhaps chaining everything without saving the files on disk?
using HTTP, GZip, IDX # https://github.com/jlegare/IDX.git
r = HTTP.get("http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz", cookies=true);
destPath = joinpath(dirname(Base.find_package("Bmlt")),"..","test","data","mnist")
zippedFile = joinpath(destPath,"test.gz")
unZippedFile = joinpath(destPath,"test.idx3")
open(zippedFile,"w") do f
write(f,String(r.body))
end
fh = GZip.open(zippedFile)
open(unZippedFile,"w") do f
write(f,read(fh))
end
train_set = load(unZippedFile)
img1 = train_set[3][:,:,1]