0

I use the initialization of the following type:

if (!Py_IsInitialized()) {
        Py_Initialize();
        qInfo() << "INIT LIBs";
        PyRun_SimpleString("import sys");
        PyRun_SimpleString("import os");
        PyRun_SimpleString("import cv2");
        PyRun_SimpleString("import gc");
        PyRun_SimpleString("import numpy");
        PyRun_SimpleString("import tensorflow as tf");

        PyRun_SimpleString("from datetime import datetime");
        PyRun_SimpleString("from utils import label_map_util");
        PyRun_SimpleString("from utils import visualization_utils as vis_util");
    }

Next, I have frame processing with pyrun_simplestring. I know this is a bad way). But I need to know how I can clean the entire interpreter, including imported modules. I ask this because processing works fine for me until the moment of repeated interaction with the interpreter. If I start working with the translator again, the program will crash when interacting with numpy. Thanks for the help.

PyRun_SimpleString("image_expanded = numpy.expand_dims(image, axis = 0)")
5

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.