One way is to use imageDatastore.
datasetPath = fullfile('/path/to/dataset');
imds = imageDatastore(datasetPath, ...
'IncludeSubfolders',true,'LabelSource','foldernames');
Refer to the Load and Explore Image Data section in the following example:
For more information on imageDatastore, you can refer to the below link