Я хочу позвонить своему модулю Python из Matlab. Я получил ошибку: < /p>
Error using numpy_ops>init thinc.backends.numpy_ops
< /code>
ошибка Python: < /p>
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject.
< /code>
Сценарий Python выглядит следующим образом < /p>
import spacy
def text_recognizer(model_path, text):
try:
# Load the trained model
nlp = spacy.load(model_path)
print("Model loaded successfully.")
# Process the given text
doc = nlp(text)
ent_labels = [(ent.text, ent.label_) for ent in doc.ents]
return ent_labels
< /code>
Скрипт Matlab заключается в следующем < /p>
% Set up the Python environment
pe = pyenv;
py.importlib.import_module('final_output');
% Add the directory containing the Python script to the Python path
path_add = fileparts(which('final_output.py'));
if count(py.sys.path, path_add) == 0
insert(py.sys.path, int64(0), path_add);
end
% Define model path and text to process
model_path = 'D:\trained_model\\output\\model-best';
text = 'Roses are red';
% Call the Python function
pyOut = py.final_output.text_recognizer(model_path, text);
% Convert the output to a MATLAB cell array
entity_labels = cell(pyOut);
disp(entity_labels);
< /code>
Я нашел одно решение для обновления Numpy, что я сделал, но ничего не изменилось. Я использую Python 3.9 и Numpy версию 2.0.0 < /p>
Ошибка была получена, когда я пытался вызвать модуль Python с помощью скрипта Matlab. < /P>
Как я могу решить проблему?
Подробнее здесь: https://stackoverflow.com/questions/786 ... ed-96-from
Размер numpy.dtype изменился, может указывать на бинарную несовместимость. Ожидается 96 от заголовка C, получил 88 от Py ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение