CUDA9.0找不到
安装CUDA9.0 与对应cudnn7.6.5 即可,显卡版本太高会导致报错:CUDA与系统显卡驱动不匹配,不用在意他继续往下安装就行。
AttributeError: module ‘tensorflow.python.keras.backend’ has no attribute ‘get_graph’
这是因为Keras的版本与TensorFlow的版本不匹配,卸载现有的,安装指定版本的Keras就行
可以看到与TF1.9匹配的Keras版本号为2.2.0
(tensorflow1.9) C:\PycharmProjects\text-detection-ocr-master>conda list
# packages in environment at C:\ProgramData\Anaconda3\envs\tensorflow1.9:
#
# Name Version Build Channel
absl-py 0.9.0 pypi_0 pypi
astor 0.8.1 pypi_0 pypi
certifi 2020.4.5.1 py36_0
cycler 0.10.0 pypi_0 pypi
dlocr 0.1-SNAPSHOT pypi_0 pypi
gast 0.3.3 pypi_0 pypi
grpcio 1.29.0 pypi_0 pypi
h5py 2.10.0 pypi_0 pypi
importlib-metadata 1.6.0 pypi_0 pypi
keras 2.3.1 pypi_0 pypi
keras-applications 1.0.8 pypi_0 pypi
keras-preprocessing 1.1.2 pypi_0 pypi
kiwisolver 1.2.0 pypi_0 pypi
markdown 3.2.2 pypi_0 pypi
matplotlib 3.2.1 pypi_0 pypi
numpy 1.18.4 pypi_0 pypi
opencv-python 4.2.0.34 pypi_0 pypi
pandas 1.0.4 pypi_0 pypi
pillow 7.1.2 pypi_0 pypi
pip 20.0.2 py36_3
protobuf 3.12.2 pypi_0 pypi
pyparsing 2.4.7 pypi_0 pypi
python 3.6.10 h9f7ef89_2
python-dateutil 2.8.1 pypi_0 pypi
pytz 2020.1 pypi_0 pypi
pyyaml 5.3.1 pypi_0 pypi
scipy 1.4.1 pypi_0 pypi
setuptools 39.1.0 pypi_0 pypi
six 1.15.0 pypi_0 pypi
sqlite 3.31.1 h2a8f88b_1
tensorboard 1.9.0 pypi_0 pypi
tensorflow-gpu 1.9.0 pypi_0 pypi
termcolor 1.1.0 pypi_0 pypi
vc 14.1 h0510ff6_4
vs2015_runtime 14.16.27012 hf0eaf9b_2
werkzeug 1.0.1 pypi_0 pypi
wheel 0.34.2 py36_0
wincertstore 0.2 py36h7fe50ca_0
xmltodict 0.12.0 pypi_0 pypi
zipp 3.1.0 pypi_0 pypi
zlib 1.2.11 h62dcd97_4
可以看到Keras版本号2.3.0,太高了。
pip install keras==2.2.0
卸载2.3,安装2.2
(tensorflow1.9) C:\PycharmProjects\text-detection-ocr-master>pip install keras==2.2.0
Collecting keras==2.2.0
Downloading Keras-2.2.0-py2.py3-none-any.whl (300 kB)
|████████████████████████████████| 300 kB 819 kB/s
Collecting keras-preprocessing==1.0.1
Downloading Keras_Preprocessing-1.0.1-py2.py3-none-any.whl (26 kB)
Collecting keras-applications==1.0.2
Downloading Keras_Applications-1.0.2-py2.py3-none-any.whl (43 kB)
|████████████████████████████████| 43 kB 3.4 MB/s
Requirement already satisfied: scipy>=0.14 in c:\programdata\anaconda3\envs\tensorflow1.9\lib\site-packages (from keras==2.2.0) (1.4.1)
Requirement already satisfied: six>=1.9.0 in c:\programdata\anaconda3\envs\tensorflow1.9\lib\site-packages (from keras==2.2.0) (1.15.0)
Requirement already satisfied: pyyaml in c:\programdata\anaconda3\envs\tensorflow1.9\lib\site-packages (from keras==2.2.0) (5.3.1)
Requirement already satisfied: h5py in c:\programdata\anaconda3\envs\tensorflow1.9\lib\site-packages (from keras==2.2.0) (2.10.0)
Requirement already satisfied: numpy>=1.9.1 in c:\programdata\anaconda3\envs\tensorflow1.9\lib\site-packages (from keras==2.2.0) (1.18.4)
Installing collected packages: keras-preprocessing, keras-applications, keras
Attempting uninstall: keras-preprocessing
Found existing installation: Keras-Preprocessing 1.1.2
Uninstalling Keras-Preprocessing-1.1.2:
Successfully uninstalled Keras-Preprocessing-1.1.2
Attempting uninstall: keras-applications
Found existing installation: Keras-Applications 1.0.8
Uninstalling Keras-Applications-1.0.8:
Successfully uninstalled Keras-Applications-1.0.8
Attempting uninstall: keras
Found existing installation: Keras 2.3.1
Uninstalling Keras-2.3.1:
Successfully uninstalled Keras-2.3.1
Successfully installed keras-2.2.0 keras-applications-1.0.2 keras-preprocessing-1.0.1
(tensorflow1.9) C:\PycharmProjects\text-detection-ocr-master>conda list
# packages in environment at C:\ProgramData\Anaconda3\envs\tensorflow1.9:
#
# Name Version Build Channel
absl-py 0.9.0 pypi_0 pypi
astor 0.8.1 pypi_0 pypi
certifi 2020.4.5.1 py36_0
cycler 0.10.0 pypi_0 pypi
dlocr 0.1-SNAPSHOT pypi_0 pypi
gast 0.3.3 pypi_0 pypi
grpcio 1.29.0 pypi_0 pypi
h5py 2.10.0 pypi_0 pypi
importlib-metadata 1.6.0 pypi_0 pypi
keras 2.2.0 pypi_0 pypi
keras-applications 1.0.2 pypi_0 pypi
keras-preprocessing 1.0.1 pypi_0 pypi
kiwisolver 1.2.0 pypi_0 pypi
markdown 3.2.2 pypi_0 pypi
matplotlib 3.2.1 pypi_0 pypi
numpy 1.18.4 pypi_0 pypi
opencv-python 4.2.0.34 pypi_0 pypi
pandas 1.0.4 pypi_0 pypi
pillow 7.1.2 pypi_0 pypi
pip 20.0.2 py36_3
protobuf 3.12.2 pypi_0 pypi
pyparsing 2.4.7 pypi_0 pypi
python 3.6.10 h9f7ef89_2
python-dateutil 2.8.1 pypi_0 pypi
pytz 2020.1 pypi_0 pypi
pyyaml 5.3.1 pypi_0 pypi
scipy 1.4.1 pypi_0 pypi
setuptools 39.1.0 pypi_0 pypi
six 1.15.0 pypi_0 pypi
sqlite 3.31.1 h2a8f88b_1
tensorboard 1.9.0 pypi_0 pypi
tensorflow-gpu 1.9.0 pypi_0 pypi
termcolor 1.1.0 pypi_0 pypi
vc 14.1 h0510ff6_4
vs2015_runtime 14.16.27012 hf0eaf9b_2
werkzeug 1.0.1 pypi_0 pypi
wheel 0.34.2 py36_0
wincertstore 0.2 py36h7fe50ca_0
xmltodict 0.12.0 pypi_0 pypi
zipp 3.1.0 pypi_0 pypi
zlib 1.2.11 h62dcd97_4
输入python -m dlocr -h
测试一下
(tensorflow1.9) C:\PycharmProjects\text-detection-ocr-master>python -m dlocr -h
Using TensorFlow backend.
C:\ProgramData\Anaconda3\envs\tensorflow1.9\lib\site-packages\tensorflow\python\framework\dtypes.py:523: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
C:\ProgramData\Anaconda3\envs\tensorflow1.9\lib\site-packages\tensorflow\python\framework\dtypes.py:524: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
C:\ProgramData\Anaconda3\envs\tensorflow1.9\lib\site-packages\tensorflow\python\framework\dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
C:\ProgramData\Anaconda3\envs\tensorflow1.9\lib\site-packages\tensorflow\python\framework\dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
C:\ProgramData\Anaconda3\envs\tensorflow1.9\lib\site-packages\tensorflow\python\framework\dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
C:\ProgramData\Anaconda3\envs\tensorflow1.9\lib\site-packages\tensorflow\python\framework\dtypes.py:532: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
usage: __main__.py [-h] --image_path IMAGE_PATH
[--dict_file_path DICT_FILE_PATH]
[--densenet_config_path DENSENET_CONFIG_PATH]
[--ctpn_config_path CTPN_CONFIG_PATH]
[--ctpn_weight_path CTPN_WEIGHT_PATH]
[--densenet_weight_path DENSENET_WEIGHT_PATH]
[--adjust ADJUST]
optional arguments:
-h, --help show this help message and exit
--image_path IMAGE_PATH
图像位置
--dict_file_path DICT_FILE_PATH
字典文件位置
--densenet_config_path DENSENET_CONFIG_PATH
densenet模型配置文件位置
--ctpn_config_path CTPN_CONFIG_PATH
ctpn模型配置文件位置
--ctpn_weight_path CTPN_WEIGHT_PATH
ctpn模型权重文件位置
--densenet_weight_path DENSENET_WEIGHT_PATH
densenet模型权重文件位置
--adjust ADJUST 是否对图像进行适当裁剪
发现报错!!!,原因numpy版本太高,降版本pip install numpy==1.16.0
C:\ProgramData\Anaconda3\envs\tensorflow1.9\lib\site-packages\tensorflow\python\framework\dtypes.py:523: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
C:\ProgramData\Anaconda3\envs\tensorflow1.9\lib\site-packages\tensorflow\python\framework\dtypes.py:524: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
C:\ProgramData\Anaconda3\envs\tensorflow1.9\lib\site-packages\tensorflow\python\framework\dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
C:\ProgramData\Anaconda3\envs\tensorflow1.9\lib\site-packages\tensorflow\python\framework\dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
C:\ProgramData\Anaconda3\envs\tensorflow1.9\lib\site-packages\tensorflow\python\framework\dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
C:\ProgramData\Anaconda3\envs\tensorflow1.9\lib\site-packages\tensorflow\python\framework\dtypes.py:532: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
再次尝试
(tensorflow1.9) C:\PycharmProjects\text-detection-ocr-master>python -m dlocr -h
Using TensorFlow backend.
usage: __main__.py [-h] --image_path IMAGE_PATH
[--dict_file_path DICT_FILE_PATH]
[--densenet_config_path DENSENET_CONFIG_PATH]
[--ctpn_config_path CTPN_CONFIG_PATH]
[--ctpn_weight_path CTPN_WEIGHT_PATH]
[--densenet_weight_path DENSENET_WEIGHT_PATH]
[--adjust ADJUST]
optional arguments:
-h, --help show this help message and exit
--image_path IMAGE_PATH
图像位置
--dict_file_path DICT_FILE_PATH
字典文件位置
--densenet_config_path DENSENET_CONFIG_PATH
densenet模型配置文件位置
--ctpn_config_path CTPN_CONFIG_PATH
ctpn模型配置文件位置
--ctpn_weight_path CTPN_WEIGHT_PATH
ctpn模型权重文件位置
--densenet_weight_path DENSENET_WEIGHT_PATH
densenet模型权重文件位置
--adjust ADJUST 是否对图像进行适当裁剪