演示tensorflow图像识别案例。
参考文档:https://blog.csdn.net/shadown1ght/article/details/78571187
作者:李继武
安装python3.5环境
如果环境中已有Python3可跳过;
1. 下载Python3安装包
wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tar.xz
2. 解压,编译及安装
tar xvf Python-3.5.0.tar.xz
./configure
make && make install
3. 验证安装
安装tensorflow模块
1. 升级pip模块
下载pip-18.1安装包
wget https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl
安装
pip3 install pip-18.1-py2.py3-none-any.whl
2. 安装tensorflow
pip3 install tensorflow
3. 验证安装
导入数据
1. 创建工作目录
mkdir -p /data/tf_demo
2. 将数据集上传到该目录下
3. 编写代码
省份简称训练+识别代码(保存文件名为train-license-province.py):
城市代号训练+识别代码(保存文件名为train-license-letters.py):
车牌编号训练+识别代码(保存文件名为train-license-digits.py):
4. 训练
保存好上面三个python脚本后,我们首先进行省份简称训练。
python3 train-license-province.py train
然后进行省份简称识别,在命令行输入执行如下命令:
python3 train-license-province.py predict
执行城市代号训练(相当于训练26个字母):
python3 train-license-letters.py train
识别城市代号:
python3 train-license-letters.py predict
执行车牌编号训练(相当于训练24个字母+10个数字,我国交通法规规定车牌编号中不包含字母I和O):
python3 train-license-digits.py train
识别车牌编号:
python3 train-license-digits.py predict
与下方的测试图片对比,识别成功:
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有