Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
5992be4a
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
1 年多 前同步成功
通知
115
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看板
提交
5992be4a
编写于
9月 26, 2021
作者:
C
cuicheng01
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add multilabel feature
上级
af9aae73
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
45 addition
and
171 deletion
+45
-171
docs/en/advanced_tutorials/multilabel/multilabel_en.md
docs/en/advanced_tutorials/multilabel/multilabel_en.md
+45
-35
ppcls/configs/quick_start/MobileNetV1_multilabel.yaml
ppcls/configs/quick_start/MobileNetV1_multilabel.yaml
+0
-129
train.sh
train.sh
+0
-7
未找到文件。
docs/en/advanced_tutorials/multilabel/multilabel_en.md
浏览文件 @
5992be4a
...
@@ -25,58 +25,68 @@ tar -xf NUS-SCENE-dataset.tar
...
@@ -25,58 +25,68 @@ tar -xf NUS-SCENE-dataset.tar
cd ../../
cd ../../
```
```
##
Environment
##
Training
### Download pretrained model
```
shell
export
CUDA_VISIBLE_DEVICES
=
0,1,2,3
python3
-m
paddle.distributed.launch
\
--gpus
=
"0,1,2,3"
\
tools/train.py
\
-c
./ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml
```
You can use the following commands to download the pretrained model of ResNet50_vd.
After training for 10 epochs, the best accuracy over the validation set should be around 0.95.
## Evaluation
```
bash
```
bash
mkdir
pretrained
python tools/eval.py
\
cd
pretrained
-c
./ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml
\
wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNet50_vd_pretrained.pdparams
-o
Arch.pretrained
=
"./output/MobileNetV1/best_model"
cd
../
```
```
##
Training
##
Prediction
```
shell
```
bash
export
CUDA_VISIBLE_DEVICES
=
0
python3 tools/infer.py
python
-m
paddle.distributed.launch
\
-c
./ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml
\
--gpus
=
"0"
\
-o
Arch.pretrained
=
"./output/MobileNetV1/best_model"
tools/train.py
\
-c
./configs/quick_start/ResNet50_vd_multilabel.yaml
```
```
After training for 10 epochs, the best accuracy over the validation set should be around 0.72.
You will get multiple output such as the following:
```
[{'class_ids': [6, 13, 17, 23, 26, 30], 'scores': [0.95683, 0.5567, 0.55211, 0.99088, 0.5943, 0.78767], 'file_name': './deploy/images/0517_2715693311.jpg', 'label_names': []}]
```
## Evaluation
## Prediction based on prediction engine
### Export model
```
bash
```
bash
python tools/eval.py
\
python3 tools/export_model.py
\
-c
./configs/quick_start/ResNet50_vd_multilabel.yaml
\
-c
./ppcls/configs/quick_start/professional/MobileNetV1_multilabel.yaml
\
-o
pretrained_model
=
"./output/ResNet50_vd/best_model/ppcls"
\
-o
Arch.pretrained
=
"./output/MobileNetV1/best_model"
-o
load_static_weights
=
False
```
```
The
metric of evaluation is based on mAP, which is commonly used in multilabel task to show model perfermance. The mAP over validation set should be around 0.57.
The
default path of the inference model is under the current path
`./inference`
## Prediction
### Prediction based on prediction engine
Enter the deploy directory:
```
bash
```
bash
python tools/infer/infer.py
\
cd
./deploy
-i
"./dataset/NUS-WIDE-SCENE/NUS-SCENE-dataset/images/0199_434752251.jpg"
\
```
--model
ResNet50_vd
\
--pretrained_model
"./output/ResNet50_vd/best_model/ppcls"
\
Prediction based on prediction engine:
--use_gpu
True
\
--load_static_weights
False
\
```
--multilabel
True
\
python3 python/predict_cls.py
\
--class_num
33
-c configs/inference_multilabel_cls.yaml
```
```
You will get multiple output such as the following:
You will get multiple output such as the following:
```
class id: 3, probability: 0.6025
```
class id: 23, probability: 0.5491
0517_2715693311.jpg: class id(s): [6, 13, 17, 23, 26, 30], score(s): [0.96, 0.56, 0.55, 0.99, 0.59, 0.79], label_name(s): []
class id: 32, probability: 0.7006
```
```
\ No newline at end of file
ppcls/configs/quick_start/MobileNetV1_multilabel.yaml
已删除
100644 → 0
浏览文件 @
af9aae73
# global configs
Global
:
checkpoints
:
null
pretrained_model
:
null
output_dir
:
./output/
device
:
gpu
save_interval
:
1
eval_during_train
:
True
eval_interval
:
1
epochs
:
10
print_batch_step
:
10
use_visualdl
:
False
# used for static mode and model export
image_shape
:
[
3
,
224
,
224
]
save_inference_dir
:
./inference
use_multilabel
:
True
# model architecture
Arch
:
name
:
MobileNetV1
class_num
:
33
pretrained
:
True
# loss function config for traing/eval process
Loss
:
Train
:
-
MultiLabelLoss
:
weight
:
1.0
Eval
:
-
MultiLabelLoss
:
weight
:
1.0
Optimizer
:
name
:
Momentum
momentum
:
0.9
lr
:
name
:
Cosine
learning_rate
:
0.1
regularizer
:
name
:
'
L2'
coeff
:
0.00004
# data loader for train and eval
DataLoader
:
Train
:
dataset
:
name
:
MultiLabelDataset
image_root
:
./dataset/NUS-SCENE-dataset/images/
cls_label_path
:
./dataset/NUS-SCENE-dataset/multilabel_train_list.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
RandCropImage
:
size
:
224
-
RandFlipImage
:
flip_code
:
1
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
sampler
:
name
:
DistributedBatchSampler
batch_size
:
64
drop_last
:
False
shuffle
:
True
loader
:
num_workers
:
4
use_shared_memory
:
True
Eval
:
dataset
:
name
:
MultiLabelDataset
image_root
:
./dataset/NUS-SCENE-dataset/images/
cls_label_path
:
./dataset/NUS-SCENE-dataset/multilabel_test_list.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
resize_short
:
256
-
CropImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
sampler
:
name
:
DistributedBatchSampler
batch_size
:
256
drop_last
:
False
shuffle
:
False
loader
:
num_workers
:
4
use_shared_memory
:
True
Infer
:
infer_imgs
:
dataset/NUS-SCENE-dataset/images/0001_109549716.jpg
batch_size
:
10
transforms
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
resize_short
:
256
-
CropImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
-
ToCHWImage
:
PostProcess
:
name
:
MutiLabelTopk
topk
:
5
class_id_map_file
:
None
Metric
:
Train
:
-
HammingDistance
:
-
AccuracyScore
:
Eval
:
-
HammingDistance
:
-
AccuracyScore
:
train.sh
已删除
100755 → 0
浏览文件 @
af9aae73
#!/usr/bin/env bash
# for single card train
# python3.7 tools/train.py -c ./ppcls/configs/ImageNet/ResNet/ResNet50.yaml
# for multi-cards train
python3.7
-m
paddle.distributed.launch
--gpus
=
"0"
tools/train.py
-c
./MobileNetV2.yaml
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录