-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from MATLAB-Community-Toolboxes-at-INCF/import…
…_fixing Import fixing
- Loading branch information
Showing
9 changed files
with
61 additions
and
9 deletions.
There are no files selected for viewing
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,38 @@ | ||
function net = openTensorFlowNetwork(tensorFlowZipFile, namespaceName) | ||
% OPENTENSORFLOWNETWORK - open a TensorFlow network zip file | ||
% | ||
% NET = OPENTENSORFLOWNETWORK(TENSORFLOWZIPFILE, NAMESPACENAME) | ||
% | ||
% Open a network from a saved TensorFlow network zip file. | ||
% | ||
% The ZIP file should have a directory with subdirectories "assets", | ||
% "variables" and files "keras_metadata.pb" and "saved_model.pb". | ||
% | ||
% NAMESPACENAME is the namespace to be used to import the network. | ||
% | ||
% The namespace is created in the directory: | ||
% [DEEP_INTERPOLATION_ROOT filesep 'preTrainedModels' filesep 'TensorFlowNetworks'] | ||
% | ||
% | ||
|
||
tfnet_path = fullfile(deepinterp.toolboxpath,'pretrainedModels','TensorFlowNetworks'); | ||
|
||
output_files = unzip(tensorFlowZipFile,tfnet_path); | ||
modelFolder = fileparts(output_files{1}); | ||
net_namespace = namespaceName; | ||
currDir = pwd; | ||
|
||
did_it_fail = false; | ||
|
||
try, | ||
cd(tfnet_path); | ||
net = importNetworkFromTensorFlow(modelFolder,Namespace=namespaceName); | ||
catch, | ||
did_it_fail = true; | ||
end; | ||
|
||
cd(currDir); | ||
|
||
if did_it_fail, | ||
error(lasterr); | ||
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
Binary file not shown.
Binary file not shown.
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 @@ | ||
|
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,8 @@ | ||
#The following snippet is executed in Python 3.9 with TensorFlow 2.10. Currently, the import functionality in MATLAB support upto TF 2.10. | ||
#The command to install TensorFlow 2.10 is: | ||
#pip install tensorflow==2.10 | ||
|
||
import tensorflow as tf | ||
model = tf.keras.models.load_model('2019_09_11_23_32_unet_single_1024_mean_absolute_error_Ai93-0450.h5') | ||
model.save('TF_2019_09_11_23_32_unet_single_1024_mean_absolute_error_Ai93-0450', save_format='tf') | ||
|
Empty file.
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