【超简单】使用TensorFlow训练和部署图像分类模型

一、简介

使用TensorFlow和OpenCV实现图像分类。

按照流程图运行程序,可以非常简便地完成图像预处理、生成数据集、训练模型和部署模型。

四个程序的功能如下:

preprocess.py : 对图像进行重命名和调整大小,建议拍摄形状为正方形,调整后的图像尺寸为640*640

train.py : 生成数据集和训练模型

test_model.py : 检查新生成模型的表现(性能)

deploy.py : 使用摄像头运行模型,对物体进行实时分类

二、准备工作

1、安装Visual Studio Community 2022

安装软件,并勾选安装“使用C/C++桌面开发”选项。

2、安装Anaconda

安装完成后,运行Anaconda Prompt,依次运行以下代码。

conda create -n tensorflow python>3.8
activate tensorflow
pip install tensorflow>2.8
pip install labelImg
pip install opencv-python
pip install pillow

三、使用方法

1、把拍摄好的图片放到voc_dataset文件夹中,子文件夹按照“类标签”进行存放。

2、运行preprocess.py程序,重命名图片、调整图片尺寸。

3、运行labelImg,具体的使用方法见以下连接或自行搜索。GitHub - heartexlabs/labelImg: LabelImg is now part of the Label Studio community. The popular image annotation tool created by Tzutalin is no longer actively being developed, but you can check out Label Studio, the open source data labeling tool for images, text, hypertext, audio, video and time-series data.LabelImg is now part of the Label Studio community. The popular image annotation tool created by Tzutalin is no longer actively being developed, but you can check out Label Studio, the open source data labeling tool for images, text, hypertext, audio, video and time-series data. - GitHub - heartexlabs/labelImg: LabelImg is now part of the Label Studio community. The popular image annotation tool created by Tzutalin is no longer actively being developed, but you can check out Label Studio, the open source data labeling tool for images, text, hypertext, audio, video and time-series data.https://github.com/heartexlabs/labelImg

4、运行train.py程序,生成一个新的模型。

5、运行test_model.py程序,测试模型的准确率。

6、运行deploy.py程序,可以在计算机或嵌入式设备中运行,执行实时物体分类。

四、流程图

五、文件【百度网盘分享】

见本人博客文章末尾,使用TensorFlow生成自定义模型 – 科创研学社

六、GitHub

GitHub - icexiaoyou/Simple-TF-Image-Classification: Using TensorFlow Keras to train and deploy your custom models. In the repository, data preprocessing and preparing datasets is done automatically. Everything is simple and friendly to the AI Dev newer!Using TensorFlow Keras to train and deploy your custom models. In the repository, data preprocessing and preparing datasets is done automatically. Everything is simple and friendly to the AI Dev newer! - GitHub - icexiaoyou/Simple-TF-Image-Classification: Using TensorFlow Keras to train and deploy your custom models. In the repository, data preprocessing and preparing datasets is done automatically. Everything is simple and friendly to the AI Dev newer!https://github.com/icexiaoyou/Simple-TF-Image-Classification

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值