function downloadTrainedSpaceNetDistance(url,destination)
% DOWNLOADTRAINEDSPACENETDISTANCE Helper function to download the pretrained 
% DeepLab v3+ network to semantically segment SpaceNet images into 129 classes.
%

%   Copyright 2020 The MathWorks, Inc.

filename = 'deeplabv3plusResNet50SpaceNetDistance.mat';
netDirFullPath = destination;
netFileFullPath = fullfile(destination,filename);

if ~exist(netFileFullPath,'file')
    fprintf('Downloading pretrained DeepLab v3+ network for SpaceNet data (129 classes).\n');
    fprintf('This can take several minutes to download...\n');
    if ~exist(netDirFullPath,'dir')
        mkdir(netDirFullPath);
    end
    websave(netFileFullPath,url);
    fprintf('Done.\n\n');
else
    fprintf('Pretrained DeepLab v3+ network for SpaceNet data set (129 classes) already exists.\n\n');
end
end