AI-MXNet-Gluon-ModelZoo
view release on metacpan or search on metacpan
lib/AI/MXNet/Gluon/ModelZoo/ModelStore.pm view on Meta::CPAN
$root =~ s/~/$ENV{HOME}/;
my $file_path = "$root/$file_name.params";
my $sha1_hash = $_model_sha1{$name};
if(-f $file_path)
{
if(check_sha1($file_path, $sha1_hash))
{
return $file_path;
}
else
{
warn("Mismatch in the content of model file detected. Downloading again.\n");
}
}
else
{
warn("Model file is not found. Downloading.\n");
}
if(not -d $root)
{
make_path($root);
}
my $zip_file_path = "$root/$file_name.zip";
my $repo_url = $ENV{MXNET_GLUON_REPO}//$apache_repo_url;
if($repo_url !~ /\/$/)
{
$repo_url .= '/';
}
download(
sprintf($_url_format, $repo_url, $file_name),
path=>$zip_file_path,
overwrite=>1
);
unzip($zip_file_path, $file_path);
unlink $zip_file_path;
if(check_sha1($file_path, $sha1_hash))
{
return $file_path;
}
else
{
Carp::confess("Downloaded file $file_path has different hash. Please try again.");
}
}
=head2 purge
Purge all pretrained model files in local file store.
Parameters
----------
root : str, default '~/.mxnet/models'
Location for keeping the model parameters.
=cut
method purge(Str $root='~/.mxnet/models')
{
$root =~ s/~/$ENV{HOME}/;
map { unlink } glob("$root/*.params");
}
1;
( run in 1.066 second using v1.01-cache-2.11-cpan-e93a5daba3e )