东方耀AI技术分享

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 3131|回复: 0
打印 上一主题 下一主题

[课堂笔记] 通用图像识别系统PaddleClas

[复制链接]

1365

主题

1856

帖子

1万

积分

管理员

Rank: 10Rank: 10Rank: 10

积分
14438
QQ
跳转到指定楼层
楼主
发表于 2021-6-25 15:12:30 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
通用图像识别系统PaddleClas




git clone https://github.com/PaddlePaddle/PaddleClas.git -b release/2.2
pip3 install --upgrade -r requirements.txt -i https://mirror.baidu.com/pypi/simple






搭建一个综合使用目标检测、图像分类、度量学习、图像检索的通用图像识别系统


https://github.com/PaddlePaddle/PaddleClas


多类别、小样本、数据不均衡通通不再是问题,而且它不仅可以用作商品识别,车辆、Logo、行人、人脸识别


参考文档:https://github.com/PaddlePaddle/ ... tart_recognition.md




以商品识别为例,下载demo数据集以及通用检测、识别模型,命令如下:
cd deploy
mkdir models
cd models
# 下载通用检测inference模型并解压
wget https://paddle-imagenet-models-n ... body_v1.0_infer.tar && tar -xf ppyolov2_r50vd_dcn_mainbody_v1.0_infer.tar
# 下载识别inference模型并解压
wget https://paddle-imagenet-models-n ... duct_v1.0_infer.tar && tar -xf product_ResNet50_vd_aliproduct_v1.0_infer.tar


cd ../
# 下载demo数据并解压
wget https://paddle-imagenet-models-n ... _demo_data_v1.0.tar && tar -xf recognition_demo_data_v1.0.tar




识别单张图像
python3 python/predict_system.py -c configs/inference_product.yaml
报错:
Error Message Summary:
----------------------
FatalError: `Illegal instruction` is detected by the operating system.
  [TimeInfo: *** Aborted at 1624602777 (unix time) try "date -d @1624602777" if you are using GNU date ***]
  [SignalInfo: *** SIGILL (@0x7f3438ad7b81) received by PID 19996 (TID 0x7f34b408d0c0) from PID 950893441 ***]


非法指令 (核心已转储)


gallery_xxx文件夹中存放的是用于构建索引库的原始图像
注意:这里使用了默认编译生成的库文件进行特征索引,如果与您的环境不兼容,导致程序报错,可以参考向量检索教程重新编译库文件


解决:重新编译vector_search 先文件index.so ,index.so文件和你坏境不匹配,
进入该文件夹,直接运行make即可,如果希望重新生成index.so文件,可以首先使用make clean清除已经生成的缓存,再使用make生成更新之后的库文件






基于文件夹的批量识别
如果希望预测文件夹内的图像,可以直接修改配置文件中的Global.infer_imgs字段,也可以通过下面的-o参数修改对应的配置
# 使用下面的命令使用GPU进行预测,如果希望使用CPU预测,可以在命令后面添加-o Global.use_gpu=False
python3 python/predict_system.py -c configs/inference_product.yaml -o Global.infer_imgs="./recognition_demo_data_v1.0/test_product/"




未知类别的图像识别体验
# 使用下面的命令使用GPU进行预测,如果希望使用CPU预测,可以在命令后面添加-o Global.use_gpu=False
python3.7 python/predict_system.py -c configs/inference_product.yaml -o Global.infer_imgs="./recognition_demo_data_v1.0/test_product/anmuxi.jpg"


当索引库中的图像无法覆盖我们实际识别的场景时,即在预测未知类别的图像时,我们需要将对应类别的相似图像添加到索引库中,从而完成对未知类别的图像识别,这一过程是不需要重新训练的


python3.7 python/build_gallery.py -c configs/build_product.yaml -o IndexProcess.data_file="./recognition_demo_data_v1.0/gallery_product/data_file_update.txt" -o IndexProcess.index_path="./recognition_demo_data_v1.0/gallery_product/index_update"




# 使用下面的命令使用GPU进行预测,如果希望使用CPU预测,可以在命令后面添加-o Global.use_gpu=False
python3.7 python/predict_system.py -c configs/inference_product.yaml -o Global.infer_imgs="./recognition_demo_data_v1.0/test_product/anmuxi.jpg" -o IndexProcess.index_path="./recognition_demo_data_v1.0/gallery_product/index_update"












s1.png (94.15 KB, 下载次数: 178)

s1.png

安慕希酸奶.png (76.67 KB, 下载次数: 178)

安慕希酸奶.png
让天下人人学会人工智能!人工智能的前景一片大好!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|人工智能工程师的摇篮 ( 湘ICP备2020019608号-1 )

GMT+8, 2024-5-6 16:00 , Processed in 0.220023 second(s), 29 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表