Это проект колбы и модель Keras, я получаю следующую ошибку при запуске < /p>
"C:\Users\winne\AppData\Local\Programs\Python\Python311\Lib\site-packages\keras\src\layers\core\lambda_layer.py", line 394, in _parse_function_from_config
raise ValueError(
ValueError: Requested the deserialization of a Lambda layer with a Python `lambda` inside it. This carries a potential risk of arbitrary code execution and thus it is disallowed by default. If you trust the source of the saved model, you can pass `safe_mode=False` to the loading function in order to allow Lambda layer loading.
LOAD MODEL ...
при загрузке модели с использованием model_from_jason я определил пользовательский объект с помощью Safe_mode = false , но все же получает ту же ошибку
class ImagenetClassifier(object):
def __init__(self):
print('LOAD MODEL ...')
with open('../Resource/line_model_predict.json', 'r') as f:
self.l_model_predict = model_from_json(f.read(),custom_objects={"safe_mode": False})
self.l_model_predict.load_weights('../Resource/iam_lines--12--17.373.h5')
with open('../Resource/word_model_predict.json', 'r') as f:
self.w_model_predict = model_from_json(f.read(),custom_objects={"safe_mode": False})
self.w_model_predict.load_weights('../Resource/iam_words--15--1.791.h5')
def predict_image(self, image_filename):
try:
with graph.as_default():
pred_text_model_word, pred_text_model_line = predict(self.w_model_predict, self.l_model_predict, image_filename)
return pred_text_model_word, pred_text_model_line
except Exception as err:
print('Prediction error: ', err)
return (False, 'Something went wrong when predict the '
'image. Maybe try another one?')
Подробнее здесь: https://stackoverflow.com/questions/771 ... -inside-it
Запрашивал десериализацию слоя лямбда с помощью Python `лямбда -` внутри. Вы можете перенести `safe_mode = false` на фун ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение