Global variable python code simulink
1 回表示 (過去 30 日間)
I'm trying to run a python code which uses a neural network in sumlink. It works using the "trick" of "coder.extrinsic" to use pyrunfile("testSimulink.py")
The problem is that this code loads a neural network to analyze an input image, so every time the block in simulink is called, it re loads the neural network, which is too slow for real time applications.
Do you think any idea how to keep the neural network loaded as a global variable or background in the python environment?
The extrinsinc function I'm running looks like:
function y = NNextrinsic(colored)
A = imread("test.png");
A = imresize(A, [720,1280]);
y = A;
And the simulink block is a MatlabFunction block which looks like:
function y = ANNDepth(colored)
y = z;