Compilation Issue in Deep Learning Script Dependent on External Files
조회 수: 2 (최근 30일)
이전 댓글 표시
I've encountered a dilemma while working with a deep learning script for object detection, one that heavily relies on external files. The script encompasses two pretrained models and two additional scripts. Despite meticulously compiling the script and ensuring all necessary external files are included in the 'Files required for your application to run' section, the resulting executable fails to produce any output. Instead, it merely opens a command window with no discernible result.
The directory structure resembles the following:
Rbc_detector/
├── <Code>
│ ├── My_script.m
│ └── external_files
│ ├── check.m
│ ├── CNN_detector.mat
│ ├── Segment.m
│ └── Unet.mat
├── <Input images>
└── <Output>
- Code: This directory houses the primary script. Specifically, it contains 'My_script.m' alongside a subdirectory labeled 'external_files', which comprises the essential supplementary scripts and pretrained models: 'check.m', 'CNN_detector.mat', 'Segment.m', and 'Unet.mat'.
- Input Images: Here lies the repository of images awaiting processing by the script.
- Output: The designated destination where the script should save the detection results.
Despite experimenting with various configurations, including placing the external files directly within the 'My_script' directory, the issue persists. Strangely, the script executes without any reported errors, yet no results find their way into the output file.
I'm stumped by this conundrum and would greatly appreciate any insights or suggestions to troubleshoot and resolve this perplexing compilation issue. Thank you in advance for any assistance you can provide.
댓글 수: 1
Arnav
2024년 9월 20일
@BRAHIM Could you provide your files? This will greatly help others in debugging the issue.
답변 (1개)
Himanshu
2025년 5월 16일
Hello,
The compilation issue likely stems from how the deployed application handles file paths and dependencies at runtime. When MATLAB code is compiled, the executable runs in a temporary directory, which may not preserve the original relative paths to external files (like MAT models or M helper scripts). Even if files are included in the compiler, incorrect path references or unsupported functions in deployed mode can cause silent failures.
To resolve this, ensure absolute paths are used for all external dependencies. Replace relative paths with paths dynamically generated using "mfilename('fullpath')" or "fullfile()" to locate files relative to the compiled executable's root.
For pretrained models, use "coder.loadDeepLearningNetwork()" instead of "load()" to ensure compatibility with deployment. Additionally, verify that all functions are supported for code generation using the "%#codegen" directive.
To debug, add explicit logging or "disp()" statements to track progress and write outputs to a known directory with write permissions.
If using the MATLAB Compiler ("deploytool"), confirm that the "external_files" folder is explicitly added under "Files required for your application" and that the "Input images" directory is either hardcoded or passed as an argument.
I hope this helps.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Adding custom doc에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!