Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
c33f97ee
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
大约 2 年 前同步成功
通知
118
Star
4999
Fork
1114
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
6
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleClas
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
6
合并请求
6
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
c33f97ee
编写于
10月 29, 2021
作者:
B
Bin Lu
提交者:
GitHub
10月 29, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update feature_extraction.md
上级
0ae9f106
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
12 addition
and
20 deletion
+12
-20
docs/zh_CN_tmp/image_recognition_pipeline/feature_extraction.md
...h_CN_tmp/image_recognition_pipeline/feature_extraction.md
+12
-20
未找到文件。
docs/zh_CN_tmp/image_recognition_pipeline/feature_extraction.md
浏览文件 @
c33f97ee
...
@@ -75,14 +75,17 @@ Loss:
...
@@ -75,14 +75,17 @@ Loss:
```
```
可以看到此处选用的是CELoss和TripletLoss的一个组合,两者的比例为1:1.
可以看到此处选用的是CELoss和TripletLoss的一个组合,两者的比例为1:1.
#
训练
#
4.训练、评估、推理
下面以
`ppcls/configs/Products/ResNet50_vd_SOP.yaml`
为例,介绍模型的训练、评估、推理过程
下面以
`ppcls/configs/Products/ResNet50_vd_SOP.yaml`
为例,介绍模型的训练、评估、推理过程
## 单机单卡训练
## 4.1 数据准备
首先,下载SOP数据集, 数据链接
## 4.2 训练
-
单机单卡训练
```
```
python tools/train.py -c ppcls/configs/ResNet50_vd_SOP.yaml
python tools/train.py -c ppcls/configs/ResNet50_vd_SOP.yaml
```
```
##
单机多卡训练
-
单机多卡训练
```
```
python -m paddle.distributed.launch
python -m paddle.distributed.launch
--gpus="0,1,2,3" tools/train.py
--gpus="0,1,2,3" tools/train.py
...
@@ -91,22 +94,13 @@ python -m paddle.distributed.launch
...
@@ -91,22 +94,13 @@ python -m paddle.distributed.launch
训练完成之后,会在
`output`
目录下生成
`best_model`
训练完成之后,会在
`output`
目录下生成
`best_model`
# 评估
## 4.3 评估
## 1. 设置合适的评估方式
-
单卡评估
评估方式在配置文件的Metric字段设置, 包含了Train和Eval字段,Train评估考虑到耗时较长可以选择忽略,即训练时不对训练数据评估。一般检索任务的评估方式可以选用Recal@k, Precision@k和mAP. 示例配置如下所示:
```
Metric:
Eval:
- Recallk:
topk: [1, 5]
```
## 2. 单卡评估
```
```
python tools/eval.py -c ppcls/configs/ResNet50_vd_SOP.yaml -o Global.pretrained_model = "output/ReModel/best_model"
python tools/eval.py -c ppcls/configs/ResNet50_vd_SOP.yaml -o Global.pretrained_model = "output/ReModel/best_model"
```
```
## 3.
多卡评估
-
多卡评估
```
```
python -m paddle.distributed.launch
python -m paddle.distributed.launch
--gpus="0,1,2,3" tools/eval.py
--gpus="0,1,2,3" tools/eval.py
...
@@ -114,18 +108,16 @@ python -m paddle.distributed.launch
...
@@ -114,18 +108,16 @@ python -m paddle.distributed.launch
-o Global.pretrained_model="output/ReModel/best_model"
-o Global.pretrained_model="output/ReModel/best_model"
```
```
# 推理
#
# 4.4
推理
推理过程包括两个步骤: 1) 导出推理模型; 2) 获取特征向量
推理过程包括两个步骤: 1) 导出推理模型; 2) 获取特征向量
##
1.
导出推理模型
##
# 4.4.1
导出推理模型
```
```
python tools/export_model -c xxx -o Global.pretrained_model = xxxx
python tools/export_model -c xxx -o Global.pretrained_model = xxxx
```
```
生成的推理模型位于inference目录,名字为inference.pd
*
生成的推理模型位于inference目录,名字为inference.pd
*
##
2.
获取特征向量
##
# 4.4.2
获取特征向量
```
```
cd deploy
cd deploy
python python/inference_rec.py -c configs/ O rec_inference_model_dir: "../inference/inference"
python python/inference_rec.py -c configs/ O rec_inference_model_dir: "../inference/inference"
```
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录