Skip to content

Instantly share code, notes, and snippets.

@innerlee
Created April 3, 2018 10:55
Show Gist options
  • Save innerlee/8c19b27cf0ee3b6e3cd2d5f85c10764c to your computer and use it in GitHub Desktop.
Save innerlee/8c19b27cf0ee3b6e3cd2d5f85c10764c to your computer and use it in GitHub Desktop.
addprocs()
src_path = "train"
dst_path = "/mnt/SSD/datasets/imagnet128"
mkpath(dst_path)
for folder in readdir(src_path)
println("processing folder $folder")
files = filter(f -> endswith(f, ".JPEG"), readdir(joinpath(src_path, folder)))
args = [(joinpath(src_path, folder, f), joinpath(dst_path, folder, f)) for f in files]
mkpath(joinpath(dst_path, folder))
pmap(args) do fs
try
run(`convert $(fs[1]) -resize 128x128+0+0^ -gravity center -crop 128x128+0+0 $(fs[2])`)
catch
println(">> error in $(fs[1])")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment