Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
8a8eb34d
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看板
提交
8a8eb34d
编写于
6月 04, 2021
作者:
D
dongshuilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add vehicle neck and fix bugs
上级
505c9309
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
25 addition
and
24 deletion
+25
-24
ppcls/arch/__init__.py
ppcls/arch/__init__.py
+11
-12
ppcls/configs/Vehicle/ResNet50.yaml
ppcls/configs/Vehicle/ResNet50.yaml
+4
-4
ppcls/configs/Vehicle/ResNet50_ReID.yaml
ppcls/configs/Vehicle/ResNet50_ReID.yaml
+7
-7
ppcls/loss/__init__.py
ppcls/loss/__init__.py
+1
-0
ppcls/loss/supconloss.py
ppcls/loss/supconloss.py
+2
-1
未找到文件。
ppcls/arch/__init__.py
浏览文件 @
8a8eb34d
#copyright (c) 202
0
PaddlePaddle Authors. All Rights Reserve.
#copyright (c) 202
1
PaddlePaddle Authors. All Rights Reserve.
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
...
...
@@ -17,9 +17,7 @@ import importlib
import
paddle.nn
as
nn
from
.
import
backbone
from
.
import
gears
from
.
import
backbone
,
gears
from
.backbone
import
*
from
.gears
import
build_gear
from
.utils
import
*
...
...
@@ -40,10 +38,10 @@ class RecModel(nn.Layer):
super
().
__init__
()
backbone_config
=
config
[
"Backbone"
]
backbone_name
=
backbone_config
.
pop
(
"name"
)
self
.
backbone
=
getattr
(
backbone_name
)(
**
backbone_config
)
self
.
backbone
=
eval
(
backbone_name
)(
**
backbone_config
)
if
"BackboneStopLayer"
in
config
:
backbone_stop_layer
=
config
[
"BackboneStopLayer"
]
self
.
backbone
.
stop_
lay
er
(
backbone_stop_layer
)
backbone_stop_layer
=
config
[
"BackboneStopLayer"
]
[
"name"
]
self
.
backbone
.
stop_
aft
er
(
backbone_stop_layer
)
if
"Neck"
in
config
:
self
.
neck
=
build_gear
(
config
[
"Neck"
])
...
...
@@ -55,10 +53,11 @@ class RecModel(nn.Layer):
else
:
self
.
head
=
None
def
forward
(
self
,
x
):
y
=
self
.
backbone
(
x
)
def
forward
(
self
,
x
,
label
):
x
=
self
.
backbone
(
x
)
if
self
.
neck
is
not
None
:
y
=
self
.
neck
(
y
)
x
=
self
.
neck
(
x
)
y
=
x
if
self
.
head
is
not
None
:
y
=
self
.
head
(
y
)
return
y
y
=
self
.
head
(
x
,
label
)
return
{
"features"
:
x
,
"logits"
:
y
}
ppcls/configs/Vehicle/ResNet50.yaml
浏览文件 @
8a8eb34d
...
...
@@ -21,8 +21,8 @@ Arch:
Backbone
:
name
:
"
ResNet50_last_stage_stride1"
pretrained
:
True
BackboneStop
l
ayer
:
name
:
"
adaptive_avg_pool2d_
1
"
BackboneStop
L
ayer
:
name
:
"
adaptive_avg_pool2d_
0
"
Neck
:
name
:
"
VehicleNeck"
in_channels
:
2048
...
...
@@ -91,7 +91,7 @@ DataLoader:
sampler
:
name
:
DistributedRandomIdentitySampler
batch_size
:
64
batch_size
:
128
num_instances
:
2
drop_last
:
False
shuffle
:
True
...
...
@@ -117,7 +117,7 @@ DataLoader:
order
:
'
'
sampler
:
name
:
DistributedBatchSampler
batch_size
:
64
batch_size
:
128
drop_last
:
False
shuffle
:
False
loader
:
...
...
ppcls/configs/Vehicle/ResNet50_ReID.yaml
浏览文件 @
8a8eb34d
...
...
@@ -25,8 +25,8 @@ Arch:
Backbone
:
name
:
"
ResNet50_last_stage_stride1"
pretrained
:
True
BackboneStop
l
ayer
:
name
:
"
adaptive_avg_pool2d_
1
"
BackboneStop
L
ayer
:
name
:
"
adaptive_avg_pool2d_
0
"
Neck
:
name
:
"
VehicleNeck"
in_channels
:
2048
...
...
@@ -43,9 +43,9 @@ Loss:
Train
:
-
CELoss
:
weight
:
1.0
-
TripletLossV2
:
-
SupConLoss
:
weight
:
1.0
margin
:
0.5
views
:
2
Eval
:
-
CELoss
:
weight
:
1.0
...
...
@@ -70,7 +70,7 @@ DataLoader:
dataset
:
name
:
"
VeriWild"
image_root
:
"
/work/dataset/VeRI-Wild/images/"
cls_label_path
:
"
/work/dataset/VeRI-Wild/train_test_split/
debug_train
.txt"
cls_label_path
:
"
/work/dataset/VeRI-Wild/train_test_split/
train_list_start0
.txt"
transform_ops
:
-
ResizeImage
:
size
:
224
...
...
@@ -105,7 +105,7 @@ DataLoader:
dataset
:
name
:
"
VeriWild"
image_root
:
"
/work/dataset/VeRI-Wild/images"
cls_label_path
:
"
/work/dataset/VeRI-Wild/train_test_split/
debug_test
_query.txt"
cls_label_path
:
"
/work/dataset/VeRI-Wild/train_test_split/
test_3000_id
_query.txt"
transform_ops
:
-
ResizeImage
:
size
:
224
...
...
@@ -128,7 +128,7 @@ DataLoader:
dataset
:
name
:
"
VeriWild"
image_root
:
"
/work/dataset/VeRI-Wild/images"
cls_label_path
:
"
/work/dataset/VeRI-Wild/train_test_split/
debug_test
.txt"
cls_label_path
:
"
/work/dataset/VeRI-Wild/train_test_split/
test_3000_id
.txt"
transform_ops
:
-
ResizeImage
:
size
:
224
...
...
ppcls/loss/__init__.py
浏览文件 @
8a8eb34d
...
...
@@ -11,6 +11,7 @@ from .msmloss import MSMLoss
from
.npairsloss
import
NpairsLoss
from
.trihardloss
import
TriHardLoss
from
.triplet
import
TripletLoss
,
TripletLossV2
from
.supconloss
import
SupConLoss
class
CombinedLoss
(
nn
.
Layer
):
...
...
ppcls/loss/supconloss.py
浏览文件 @
8a8eb34d
...
...
@@ -32,6 +32,7 @@ class SupConLoss(nn.Layer):
Returns:
A loss scalar.
"""
features
=
features
[
"features"
]
if
self
.
num_ids
is
None
:
self
.
num_ids
=
int
(
features
.
shape
[
0
]
/
self
.
views
)
...
...
@@ -104,4 +105,4 @@ class SupConLoss(nn.Layer):
loss
=
-
(
self
.
temperature
/
self
.
base_temperature
)
*
mean_log_prob_pos
loss
=
paddle
.
mean
(
loss
.
reshape
([
anchor_count
,
batch_size
]))
return
loss
return
{
"SupConLoss"
:
loss
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录