东方耀AI技术分享

标题: 通用图像识别系统PaddleClas [打印本页]

作者: 东方耀    时间: 2021-6-25 15:12
标题: 通用图像识别系统PaddleClas
通用图像识别系统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"

















欢迎光临 东方耀AI技术分享 (http://www.ai111.vip/) Powered by Discuz! X3.4