python中keras_无法在python 2.7中加载Keras模型以转换为Coreml

import numpy as np

import keras

from keras.models import load_model

from keras_layers.keras_layer_AnchorBoxes import AnchorBoxes

from keras_loss_function.keras_ssd_loss import SSDLoss

ssd_loss = SSDLoss(neg_pos_ratio=3, alpha=1.0)

model = load_model('my_smodel.h5', custom_objects={'AnchorBoxes': AnchorBoxes,

'compute_loss': ssd_loss.compute_loss})

当我试图加载这个模型我得到这个错误,这个代码在python 3上运行但不在python 2上 . 我想在python 2中,因为我想将此模型转换为仅支持python 2的Coreml .

我使用pip安装了tensorflow,现在我试图通过源安装它 .

ImportError Traceback (most recent call last)

in ()

1 import numpy as np

----> 2 import keras

3 from keras.models import load_model

4 from keras_layers.keras_layer_AnchorBoxes import AnchorBoxes

5 from keras_loss_function.keras_ssd_loss import SSDLoss

build/bdist.linux-x86_64/egg/keras/__init__.py in ()

build/bdist.linux-x86_64/egg/keras/utils/__init__.py in ()

build/bdist.linux-x86_64/egg/keras/utils/conv_utils.py in ()

build/bdist.linux-x86_64/egg/keras/backend/__init__.py in ()

build/bdist.linux-x86_64/egg/keras/backend/tensorflow_backend.py in ()

/home/mohsin/coreml/lib/python2.7/site-packages/tensorflow/__init__.py in ()

21 from __future__ import print_function

22

---> 23 from tensorflow.python import *

24

25

/home/mohsin/coreml/lib/python2.7/site-packages/tensorflow/python/__init__.py in ()

47 _default_dlopen_flags = sys.getdlopenflags()

48 sys.setdlopenflags(_default_dlopen_flags | ctypes.RTLD_GLOBAL)

---> 49 from tensorflow.python import pywrap_tensorflow

50 sys.setdlopenflags(_default_dlopen_flags)

51

/home/mohsin/coreml/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py in ()

26 fp.close()

27 return _mod

---> 28 _pywrap_tensorflow = swig_import_helper()

29 del swig_import_helper

30 else:

/home/mohsin/coreml/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py in swig_import_helper()

22 if fp is not None:

23 try:

---> 24 _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)

25 finally:

26 fp.close()

ImportError: /home/mohsin/coreml/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so: undefined symbol: PyUnicodeUCS4_AsUTF8String

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值