function downloadTrainedSpaceNetBuilding(url,destination)
% DOWNLOADTRAINEDSPACENETBUILDING Helper function to download the pretrained 
% DeepLab v3+ network to semantically segment SpaceNet images into 3 classes.
%

%   Copyright 2020 The MathWorks, Inc.

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

if ~exist(netFileFullPath,'file')
    fprintf('Downloading pretrained DeepLab v3+ network for SpaceNet data (3 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 (3 classes).\n\n');
end
end