-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
made pretrained models folder; made pretrained models directly builda…
…ble by name only; made a single Net class that handles all known situations
- Loading branch information
1 parent
b3dda31
commit aa9fd22
Showing
21 changed files
with
276 additions
and
170 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
function [filename,parameters] = getPretrainedModelFilename(modelName) | ||
% GETPRETRAINEDMODELFILENAME - get the file name and parameters for a pretrained model | ||
% | ||
% [FILENAME, PARAMETERS] = GETPRETRAINEDMODELFILENAME(MODELNAME) | ||
% | ||
% Returns the FILENAME and the pretrained model PARAMETERS for a given MODELNAME. | ||
% | ||
% Alternatively, one may call the function with no input arguments for a list | ||
% of valid MODELNAME entries: | ||
% | ||
% [ALLMODELNAMES] = GETPRETRAINEDMODELFILENAME() | ||
% | ||
% Example: | ||
% [filename,parameters] = deepinterp.internal.getPretrainedModelFilenam('TP-Ai93-450'); | ||
% | ||
|
||
filename = []; | ||
parameters = []; | ||
|
||
[allModelNames,allModelParameters] = deepinterp.getPretrainedModels(); | ||
|
||
if nargin<1, | ||
filename = allModelNames; | ||
return; | ||
end; | ||
|
||
idx = find(strcmpi(modelName,allModelNames)); | ||
|
||
if isempty(idx), | ||
error(['No match for ' modelName ' in known models.']); | ||
end; | ||
|
||
parameters = allModelParameters(idx); | ||
|
||
filename = fullfile(deepinterp.toolboxpath,'pretrainedModels',parameters.filename); | ||
|
||
if ~isfile(filename), | ||
% try to download | ||
FileURL = parameters.url; | ||
disp(['Downloading pretrained model...']); | ||
try, | ||
websave(filename,FileURL); | ||
catch, | ||
error(['Error downloading model.']); | ||
throw(ex); | ||
end; | ||
end; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function str = textfile2char(filename) | ||
% TEXTFILE2CHAR - Read a text file into a character string | ||
% | ||
% STR = TEXTFILE2CHAR(FILENAME) | ||
% | ||
% This function reads the entire contents of the file FILENAME into | ||
% the character string STR. | ||
% | ||
|
||
fid = fopen(filename,'rt'); | ||
if fid>0, | ||
str = char(fread(fid,Inf))'; | ||
fclose(fid); | ||
else, | ||
error(['Could not open text file named ' filename '.']); | ||
end; |
Oops, something went wrong.