Preparing the dataset

We will start the process by preparing the dataset. As images are stored in different folders, we need to create a mapping between their path and class. 

We do this by iterating over each and every folder and populating a tuple with a location of a photo and ID of the class. The resulting tuple is stored in the images array. We also shuffle the images array in the end to avoid images being ordered. Consider the following code:

using Images, MXNet, StatsBaseDATASET_DIR = "data/101_ObjectCategories"CLASSES = readdir(DATASET_DIR)images = Tuple{String,Int}[]for dir_id = 1:length(CLASSES)    dir = CLASSES[dir_id]    all_files = readdir(joinpath(DATASET_DIR, dir))    keep_files = filter(x -> endswith(x, ".jpg"), all_files) append!(images, ...

Get Hands-On Computer Vision with Julia now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.