未验证 提交 50110805 编写于 作者: H HydrogenSulfate 提交者: GitHub

update PP-ShiTuV2 introduction (#5646)

* update paddleclas to 2.5.1 in requirements.txt and add an .ttf font file

* update requirements.txt

* update introduction

* update introduction
上级 4c5c73d4
......@@ -18,15 +18,13 @@
"\n",
"#### 2.1.1 数据集:\n",
"\n",
"PP-ShiTuV2的训练数据集以 Aliproduct、GLDv2等数据集为主,详细信息可参考 [PP-ShiTuV2 实验部分](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/zh_CN/training/PP-ShiTu/feature_extraction.md#4-%E5%AE%9E%E9%AA%8C%E9%83%A8%E5%88%86)\n",
"PP-ShiTuV2的训练数据集以 Aliproduct、GLDv2等数据集为主,详细信息可参考 [PP-ShiTuV2 实验部分](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.5/docs/zh_CN/training/PP-ShiTu/feature_extraction.md#4-%E5%AE%9E%E9%AA%8C%E9%83%A8%E5%88%86)\n",
"\n",
"#### 2.1.2 模型效果速览:\n",
"\n",
"PP-ShiTuV2 在图片上的检测效果如下\n",
"PP-ShiTuV2 在图片上的识别效果如下\n",
"\n",
"![](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/images/recognition/drink_data_demo/output/100.jpeg?raw=true)\n",
"\n",
"\n"
"![](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.5/docs/images/recognition/drink_data_demo/output/100.jpeg?raw=true)"
]
},
{
......@@ -37,7 +35,14 @@
"\n",
"### 3.1 模型推理:\n",
"\n",
"- 下载 PaddleClas"
"- 安装 PaddleClas 及其依赖包"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"如果您的机器安装了 CUDA9、CUDA10 或 CUDA11,请运行以下命令安装 paddle"
]
},
{
......@@ -60,48 +65,40 @@
},
"outputs": [],
"source": [
"# 不在Jupyter Notebook上运行时需要将含 \"!\" 和 \"%\" 的语句注释,不需要运行。\n",
"%cd ~/work\n",
"\n",
"# 克隆 PaddleClas(gitee上克隆速度较快)\n",
"!git clone https://gitee.com/paddlepaddle/PaddleClas"
"!pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- 安装 PaddleClas 及其依赖包"
"如果您的机器是CPU,请运行以下命令安装"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"execution": {
"iopub.execute_input": "2022-11-08T08:26:02.622321Z",
"iopub.status.busy": "2022-11-08T08:26:02.621656Z",
"iopub.status.idle": "2022-11-08T08:26:05.016413Z",
"shell.execute_reply": "2022-11-08T08:26:05.015052Z",
"shell.execute_reply.started": "2022-11-08T08:26:02.622277Z"
},
"jupyter": {
"outputs_hidden": true
"metadata": {},
"outputs": [],
"source": [
"\n",
"!pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple"
]
},
"scrolled": true,
"tags": []
{
"cell_type": "markdown",
"metadata": {},
"source": [
"安装 paddleclas whl包"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# 进入 PaddleClas 目录\n",
"%cd ~/work/PaddleClas/\n",
"\n",
"# 安装所需依赖项\n",
"!pip install -r requirements.txt\n",
"\n",
"# 设置GPU\n",
"# %env CUDA_VISIBLE_DEVICES=0"
"!pip install paddleclas"
]
},
{
......@@ -129,61 +126,32 @@
},
"outputs": [],
"source": [
"# 进入 PaddleClas 目录\n",
"%cd ~/work/PaddleClas/\n",
"\n",
"# 创建存放主体检测、特征提取推理模型的文件夹\n",
"%mkdir -p deploy/models\n",
"\n",
"# 进入该文件夹\n",
"%cd deploy/models\n",
"\n",
"# 下载主体检测inference模型并解压\n",
"!wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar && tar -xf picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar\n",
"\n",
"# 下载特征提取inference模型并解压\n",
"!wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/PP-ShiTuV2/general_PPLCNetV2_base_pretrained_v1.0_infer.tar && tar -xf general_PPLCNetV2_base_pretrained_v1.0_infer.tar\n",
"\n",
"# 返回至deploy文件夹\n",
"%cd ~/work/PaddleClas/deploy/\n",
"\n",
"# 下载测试数据 drink_dataset_v2.0 并解压\n",
"!wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/drink_dataset_v2.0.tar && tar -xf drink_dataset_v2.0.tar"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2022-11-08T08:31:30.364422Z",
"iopub.status.busy": "2022-11-08T08:31:30.363351Z",
"iopub.status.idle": "2022-11-08T08:31:37.682006Z",
"shell.execute_reply": "2022-11-08T08:31:37.680563Z",
"shell.execute_reply.started": "2022-11-08T08:31:30.364378Z"
},
"scrolled": true,
"tags": []
},
"outputs": [],
"source": [
"# 进入 PaddleClas 目录\n",
"%cd ~/work/PaddleClas/\n",
"\n",
"# 进入deploy文件夹\n",
"%cd ./deploy\n",
"\n",
"# 对 100.jpeg 图片进行识别推理\n",
"!python python/predict_system.py -c configs/inference_general.yaml -o Global.infer_imgs=\"./drink_dataset_v2.0/test_images/100.jpeg\" -o Global.use_gpu=False"
"# 下载并解压demo数据\n",
"!wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/drink_dataset_v2.0.tar && tar -xf drink_dataset_v2.0.tar\n",
"\n",
"# 在命令行中构建索引库\n",
"!paddleclas --build_gallery=True --model_name=\"PP-ShiTuV2\" \\\n",
"-o IndexProcess.image_root=./drink_dataset_v2.0/gallery/ \\\n",
"-o IndexProcess.index_dir=./drink_dataset_v2.0/index \\\n",
"-o IndexProcess.data_file=./drink_dataset_v2.0/gallery/drink_label.txt\n",
"\n",
"# 执行图像识别命令\n",
"!paddleclas --model_name=\"PP-ShiTuV2\" --predict_type=shitu \\\n",
"-o Global.infer_imgs='./drink_dataset_v2.0/test_images/100.jpeg' \\\n",
"-o IndexProcess.index_dir='./drink_dataset_v2.0/index'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"同时识别的结果(带有检测框、对应类别以及相似度)会保存至 `PaddleClas/deploy/output/100.jpeg`,如文档开头的 [2.1.2 模型效果速览](#212-模型效果速览) 所展示。\n",
"识别的结果如下所示\n",
"```log\n",
"ppcls INFO: [{'bbox': [437, 71, 660, 728], 'rec_docs': '元气森林', 'rec_scores': 0.7740249}, {'bbox': [221, 72, 449, 701], 'rec_docs': '元气森林', 'rec_scores': 0.6950992}, {'bbox': [794, 104, 979, 652], 'rec_docs': '元气森林', 'rec_scores': 0.6305153}], filename: ./drink_dataset_v2.0/test_images/100.jpeg\n",
"ppcls INFO: Predict complete!\n",
"```\n",
"\n",
"![](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/images/recognition/drink_data_demo/output/100.jpeg?raw=true)"
"如想保存识别结果为如本文档开头所示的图片,请参考 [PP-ShiTuV2 推理部署](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.5/docs/zh_CN/models/PP-ShiTu/README.md#4-%E6%8E%A8%E7%90%86%E9%83%A8%E7%BD%B2),使用完整 PaddleClas 代码进行推理预测"
]
},
{
......@@ -193,8 +161,8 @@
"### 3.2 模型训练\n",
"\n",
"- 克隆 PaddleClas 仓库(参考 3.1模型推理 - 下载PaddleClas)\n",
"- 主体检测模型的数据集准备、开始训练、模型评估等步骤,请参考 [PP-ShiTu 主体检测 文档](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/zh_CN/training/PP-ShiTu/mainbody_detection.md)\n",
"- 特征提取模型的数据集准备、开始训练、模型评估等步骤,请参考 [PP-ShiTu 特征提取 文档](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/zh_CN/training/PP-ShiTu/feature_extraction.md#5-%E8%87%AA%E5%AE%9A%E4%B9%89%E7%89%B9%E5%BE%81%E6%8F%90%E5%8F%96)\n"
"- 主体检测模型的数据集准备、开始训练、模型评估等步骤,请参考 [PP-ShiTu 主体检测 文档](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.5/docs/zh_CN/training/PP-ShiTu/mainbody_detection.md)\n",
"- 特征提取模型的数据集准备、开始训练、模型评估等步骤,请参考 [PP-ShiTu 特征提取 文档](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.5/docs/zh_CN/training/PP-ShiTu/feature_extraction.md)\n"
]
},
{
......@@ -204,7 +172,7 @@
"## 4. 模型原理\n",
"PP-ShiTu 系列识别系统,包括本文档介绍的 PP-ShiTuV2,均由3个模块串联完成整个识别过程,如下图所示\n",
"\n",
"![PP-ShiTu系统](https://github.com/PaddlePaddle/PaddleClas/raw/develop/docs/images/structure.jpg)\n",
"![PP-ShiTu系统](https://raw.githubusercontent.com/PaddlePaddle/PaddleClas/release/2.5/docs/images/structure.jpg)\n",
"\n",
"- 主体检测:上图中的蓝色模块,主要负责检测出用户输入图片中可能的识别目标,进而裁剪出这些目标,过滤不重要的背景,减少背景的干扰。事实上这种保留主体,过滤背景的做法是实践中会采用的一种简单而有效的方法。\n",
"- 特征提取:接收 **主体检测** 模块输出的含有目标主体的裁剪后的图片,将其输入到特征提取模型中,得到对应的特征向量,作为该图片的表示特征用于接下来的检索步骤。\n",
......@@ -228,11 +196,11 @@
"\n",
"- Loss\n",
"\n",
" Loss 部分选用 Cross entropy loss 和 TripletAngularMarginLoss,在训练时以分类损失和基于角度的三元组损失来指导网络进行优化。我们基于原始的 TripletLoss (困难三元组损失)进行了改进,将优化目标从 L2 欧几里得空间更换成余弦空间,并加入了 anchor 与 positive/negtive 之间的硬性距离约束,让训练与测试的目标更加接近,提升模型的泛化能力。详细的配置文件见 [GeneralRecognitionV2_PPLCNetV2_base.yaml](https://github.com/PaddlePaddle/PaddleClas/blob/develop/ppcls/configs/GeneralRecognitionV2/GeneralRecognitionV2_PPLCNetV2_base.yaml#L63-L77)。\n",
" Loss 部分选用 Cross entropy loss 和 TripletAngularMarginLoss,在训练时以分类损失和基于角度的三元组损失来指导网络进行优化。我们基于原始的 TripletLoss (困难三元组损失)进行了改进,将优化目标从 L2 欧几里得空间更换成余弦空间,并加入了 anchor 与 positive/negtive 之间的硬性距离约束,让训练与测试的目标更加接近,提升模型的泛化能力。详细的配置文件见 [GeneralRecognitionV2_PPLCNetV2_base.yaml](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.5/ppcls/configs/GeneralRecognitionV2/GeneralRecognitionV2_PPLCNetV2_base.yaml#L63-L77)。\n",
"\n",
"- Data Augmentation\n",
"\n",
" 我们考虑到实际相机拍摄时目标主体可能出现一定的旋转而不一定能保持正立状态,因此我们在数据增强中加入了适当的 [随机旋转增强](https://github.com/PaddlePaddle/PaddleClas/blob/develop/ppcls/configs/GeneralRecognitionV2/GeneralRecognitionV2_PPLCNetV2_base.yaml#L117),以提升模型在真实场景中的检索能力。\n",
" 我们考虑到实际相机拍摄时目标主体可能出现一定的旋转而不一定能保持正立状态,因此我们在数据增强中加入了适当的 [随机旋转增强](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.5/ppcls/configs/GeneralRecognitionV2/GeneralRecognitionV2_PPLCNetV2_base.yaml#L117-L120),以提升模型在真实场景中的检索能力。\n",
"\n",
"## 5. 注意事项\n",
"PP-ShiTuV2 是在寻找在产业实践中最高性价比的图像识别方案,但考虑到不同识别场景的数据集均有各自的分布特点,以及训练时的软硬件限制,无法一次性将所有的数据集全部纳入到训练集中,经过权衡才使用了目前这套训练数据集的组合。因此推荐用户在了解自己实际业务数据集的特点之后,基于 PP-ShiTuV2 的预训练模型以及训练配置,在自己的业务数据集上进行微调甚至二次开发,以获得性能更好,更适配自己数据集的识别模型。\n",
......
......@@ -18,13 +18,13 @@
"\n",
"#### 2.1.1 dataset:\n",
"\n",
"Including Aliproduct and GLDv2. For details, please refer to [PP-ShiTuV2 Experiment Section](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/zh_CN/training/PP-ShiTu/feature_extraction.md#4-%E5%AE%9E%E9%AA%8C%E9%83%A8%E5%88%86)\n",
"Including Aliproduct and GLDv2. For details, please refer to [PP-ShiTuV2 Experiment Section](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.5/docs/zh_CN/training/PP-ShiTu/feature_extraction.md#4-%E5%AE%9E%E9%AA%8C%E9%83%A8%E5%88%86)\n",
"\n",
"#### 2.1.2 output preview:\n",
"\n",
"for example, the output of PP-ShiTuV2 on the picture is as follows\n",
"\n",
"![](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/images/recognition/drink_data_demo/output/100.jpeg?raw=true)\n"
"![](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.5/docs/images/recognition/drink_data_demo/output/100.jpeg?raw=true)\n"
]
},
{
......@@ -35,12 +35,11 @@
"\n",
"### 3.1 model inference:\n",
"\n",
"- download PaddleClas"
"- Install PaddleClas and its dependencies"
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {
"collapsed": true,
"execution": {
......@@ -56,49 +55,49 @@
"scrolled": true,
"tags": []
},
"source": [
"Install paddlepaddle-gpu if using GPU"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Statements containing \"!\" and \"%\" need to be commented out when not running on Jupyter Notebook and do not need to be run.\n",
"%cd ~/work\n",
"\n",
"!git clone https://gitee.com/paddlepaddle/PaddleClas"
"!pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- Install PaddleClas and its dependencies"
"Install paddlepaddle if using CPU"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"execution": {
"iopub.execute_input": "2022-11-08T08:26:02.622321Z",
"iopub.status.busy": "2022-11-08T08:26:02.621656Z",
"iopub.status.idle": "2022-11-08T08:26:05.016413Z",
"shell.execute_reply": "2022-11-08T08:26:05.015052Z",
"shell.execute_reply.started": "2022-11-08T08:26:02.622277Z"
},
"jupyter": {
"outputs_hidden": true
"metadata": {},
"outputs": [],
"source": [
"!pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple"
]
},
"scrolled": true,
"tags": []
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Install paddleclas whl package"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Access into PaddleClas\n",
"%cd ~/work/PaddleClas/\n",
"\n",
"# Install required dependencies\n",
"!pip install -r requirements.txt\n",
"\n",
"# set GPU environment\n",
"# %env CUDA_VISIBLE_DEVICES=0"
"!pip install paddleclas"
]
},
{
......@@ -126,61 +125,32 @@
},
"outputs": [],
"source": [
"# Access into PaddleClas\n",
"%cd ~/work/PaddleClas/\n",
"\n",
"# Create a folder for storing mainbody detection and feature extraction inference models\n",
"%mkdir -p deploy/models\n",
"\n",
"# Access into models\n",
"%cd deploy/models\n",
"\n",
"# Download the mainbody detection inference model and unzip it\n",
"!wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar && tar -xf picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar\n",
"\n",
"# Download the feature extraction inference model and unzip it\n",
"!wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/PP-ShiTuV2/general_PPLCNetV2_base_pretrained_v1.0_infer.tar && tar -xf general_PPLCNetV2_base_pretrained_v1.0_infer.tar\n",
"\n",
"# Back to deloy/\n",
"%cd ~/work/PaddleClas/deploy/\n",
"\n",
"# Download the test data drink_dataset_v2.0 and unzip it\n",
"!wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/drink_dataset_v2.0.tar && tar -xf drink_dataset_v2.0.tar"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2022-11-08T08:31:30.364422Z",
"iopub.status.busy": "2022-11-08T08:31:30.363351Z",
"iopub.status.idle": "2022-11-08T08:31:37.682006Z",
"shell.execute_reply": "2022-11-08T08:31:37.680563Z",
"shell.execute_reply.started": "2022-11-08T08:31:30.364378Z"
},
"scrolled": true,
"tags": []
},
"outputs": [],
"source": [
"# Access into PaddleClas\n",
"%cd ~/work/PaddleClas/\n",
"\n",
"# Access into deploy\n",
"%cd ./deploy\n",
"\n",
"# Perform recognition and inference on 100.jpeg\n",
"!python python/predict_system.py -c configs/inference_general.yaml -o Global.infer_imgs=\"./drink_dataset_v2.0/test_images/100.jpeg\" -o Global.use_gpu=False"
"# download and unzip demo data\n",
"!wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/drink_dataset_v2.0.tar && tar -xf drink_dataset_v2.0.tar\n",
"\n",
"# build gallery\n",
"!paddleclas --build_gallery=True --model_name=\"PP-ShiTuV2\" \\\n",
"-o IndexProcess.image_root=./drink_dataset_v2.0/gallery/ \\\n",
"-o IndexProcess.index_dir=./drink_dataset_v2.0/index \\\n",
"-o IndexProcess.data_file=./drink_dataset_v2.0/gallery/drink_label.txt\n",
"\n",
"# run recognition\n",
"!paddleclas --model_name=\"PP-ShiTuV2\" --predict_type=shitu \\\n",
"-o Global.infer_imgs='./drink_dataset_v2.0/test_images/100.jpeg' \\\n",
"-o IndexProcess.index_dir='./drink_dataset_v2.0/index'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"At the same time, the recognition results (with detection bounding box, predicted class name and similarity) will be saved to `PaddleClas/deploy/output/100.jpeg`, as [2.1.2 output preview](#212-output-preview) displayed.\n",
"the result are below\n",
"```log\n",
"ppcls INFO: [{'bbox': [437, 71, 660, 728], 'rec_docs': '元气森林', 'rec_scores': 0.7740249}, {'bbox': [221, 72, 449, 701], 'rec_docs': '元气森林', 'rec_scores': 0.6950992}, {'bbox': [794, 104, 979, 652], 'rec_docs': '元气森林', 'rec_scores': 0.6305153}], filename: ./drink_dataset_v2.0/test_images/100.jpeg\n",
"ppcls INFO: Predict complete!\n",
"```\n",
"\n",
"![](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/images/recognition/drink_data_demo/output/100.jpeg?raw=true)"
"if you need to save and visualize result as picture,please refer to [PP-ShiTuV2 inference](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.5/docs/en/PPShiTu/PPShiTuV2_introduction.md#4-inference-deployment), inference with full PaddleClas code."
]
},
{
......@@ -190,8 +160,8 @@
"### 3.2 Model training\n",
"\n",
"- clone PaddleClas repo(refer to [3.1 model inference](#31-model-inference))\n",
"- For the dataset preparation, training, evaluation and other steps of the mainbody detection model, please refer to [PP-ShiTuV2 mainbody detection doc](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/zh_CN/training/PP-ShiTu/mainbody_detection.md)\n",
"- For the dataset preparation, training, evaluation and other steps of the feature extraction model, please refer to [PP-ShiTuV2 feature extraction doc](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/zh_CN/training/PP-ShiTu/feature_extraction.md#5-%E8%87%AA%E5%AE%9A%E4%B9%89%E7%89%B9%E5%BE%81%E6%8F%90%E5%8F%96)\n"
"- For the dataset preparation, training, evaluation and other steps of the mainbody detection model, please refer to [PP-ShiTuV2 mainbody detection doc](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.5/docs/zh_CN/training/PP-ShiTu/mainbody_detection.md)\n",
"- For the dataset preparation, training, evaluation and other steps of the feature extraction model, please refer to [PP-ShiTuV2 feature extraction doc](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.5/docs/zh_CN/training/PP-ShiTu/feature_extraction.md#5-%E8%87%AA%E5%AE%9A%E4%B9%89%E7%89%B9%E5%BE%81%E6%8F%90%E5%8F%96)\n"
]
},
{
......@@ -225,11 +195,11 @@
"\n",
"- Loss\n",
"\n",
" The Loss adopts Cross entropy loss and TripletAngularMarginLoss, using classification loss and cos-similarity based triplet loss to optimize the network during training. We improved based on the original TripletLoss (Hard Triplet Loss), with replacing the optimization objective from L2 Euclidean space to cosine space, and added a hard distance constraint between anchor and positive/negtive samples, making training and testing goal more closer, and the generalization ability of the model is improved. For detailed configuration files, please refer to [GeneralRecognitionV2_PPLCNetV2_base.yaml](https://github.com/PaddlePaddle/PaddleClas/blob/develop/ppcls/configs/GeneralRecognitionV2/GeneralRecognitionV2_PPLCNetV2_base.yaml#L63-L77).\n",
" The Loss adopts Cross entropy loss and TripletAngularMarginLoss, using classification loss and cos-similarity based triplet loss to optimize the network during training. We improved based on the original TripletLoss (Hard Triplet Loss), with replacing the optimization objective from L2 Euclidean space to cosine space, and added a hard distance constraint between anchor and positive/negtive samples, making training and testing goal more closer, and the generalization ability of the model is improved. For detailed configuration files, please refer to [GeneralRecognitionV2_PPLCNetV2_base.yaml](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.5/ppcls/configs/GeneralRecognitionV2/GeneralRecognitionV2_PPLCNetV2_base.yaml#L63-L77).\n",
"\n",
"- Data Augmentation\n",
"\n",
" We consider that the mainbody may rotate to a certain extent and not maintain an upright state when the camera is shot in real scenes, so we add an [RandomRotation](https://github.com/PaddlePaddle/PaddleClas/blob/develop/ppcls/configs/GeneralRecognitionV2/GeneralRecognitionV2_PPLCNetV2_base.yaml#L117) in data augmentation to improve the generalization ability of the model in real scenes.\n",
" We consider that the mainbody may rotate to a certain extent and not maintain an upright state when the camera is shot in real scenes, so we add an [RandomRotation](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.5/ppcls/configs/GeneralRecognitionV2/GeneralRecognitionV2_PPLCNetV2_base.yaml#L117-L120) in data augmentation to improve the generalization ability of the model in real scenes.\n",
"\n",
"## 5. Note\n",
"PP-ShiTuV2 is looking for the most cost-effective image recognition solution in industrial practice. However, considering that the datasets of different recognition scenarios have their own distribution characteristics, as well as the limitations of software and hardware during training, it is difficult to integrate all datasets at one time. Therefore, it is recommended that users, after understanding the characteristics of your actual datasets, fine-tune or even make an further development on your own datasets based on the PP-ShiTuV2 pre-training model and training configuration, in order to obtain better performance and generalization.\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册