Effacer les filtres
Effacer les filtres

How to Point to the path and files when loading Running App

6 vues (au cours des 30 derniers jours)
Weiwei Luo
Weiwei Luo le 19 Nov 2021
Commenté : Weiwei Luo le 23 Nov 2021
I design an app to load a pre-train deep learning model to do image segmentation. The pretrained model is placed in a folder and included during packaging the app. My wish is to automatically load the model. However, it doesn't seen to be the way. The following is my starup function of the app.
I have two folders, v5_function and v5_model. During the packaging, these two folders are added in. And then after the installation of the app, I can find them in the following folder:
C:\Users\[user name]\AppData\Roaming\MathWorks\MATLAB Add-Ons\Apps\OCTv5\
I want the app to automatically include the functions in v5_function, which there is no issue; then load the model files from the v5_folder. However, isempty(app.model_file) is always 1.
Can anyone tell me what is wrong with the line
app.model_file = dir('.\v5_model\model*.mat');
and is the addpath(genpath(... )) used in the right way?
function startupFcn(app)
addpath(genpath('.\v5_function'));
app.model_file = dir('.\v5_model\model*.mat');
while isempty(app.model_file)
msgbox('No DL model file. Please specify model file folder.');
start_path=pwd;
inputfolder_name = uigetdir(start_path);
app.model_file = dir([inputfolder_name, filesep, 'model*.mat']);
end
% Other initialization code
....
end
  2 commentaires
Weiwei Luo
Weiwei Luo le 23 Nov 2021
Thank you Geoff! The following line helps!
absPath = fileparts(mfilename('fullpath')); % absolute path to the folder containing the mlapp file

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by