Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
d8c1d824
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看板
未验证
提交
d8c1d824
编写于
7月 07, 2022
作者:
W
Walter
提交者:
GitHub
7月 07, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1978 from HydrogenSulfate/add_reid_doc
add reid docs and images
上级
7d1fe2c8
bcc6aa3a
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
866 addition
and
113 deletion
+866
-113
deploy/python/preprocess.py
deploy/python/preprocess.py
+38
-11
docs/en/algorithm_introduction/reid.md
docs/en/algorithm_introduction/reid.md
+363
-0
docs/images/reid/reid_overview.jpg
docs/images/reid/reid_overview.jpg
+0
-0
docs/images/reid/strong-baseline.jpg
docs/images/reid/strong-baseline.jpg
+0
-0
docs/zh_CN/algorithm_introduction/reid.md
docs/zh_CN/algorithm_introduction/reid.md
+363
-0
ppcls/configs/reid/strong_baseline/baseline.yaml
ppcls/configs/reid/strong_baseline/baseline.yaml
+30
-30
ppcls/configs/reid/strong_baseline/softmax_triplet.yaml
ppcls/configs/reid/strong_baseline/softmax_triplet.yaml
+36
-36
ppcls/configs/reid/strong_baseline/softmax_triplet_with_center.yaml
...igs/reid/strong_baseline/softmax_triplet_with_center.yaml
+36
-36
未找到文件。
deploy/python/preprocess.py
浏览文件 @
d8c1d824
...
...
@@ -27,6 +27,7 @@ import cv2
import
numpy
as
np
import
importlib
from
PIL
import
Image
from
paddle.vision.transforms
import
ToTensor
,
Normalize
from
python.det_preprocess
import
DetNormalizeImage
,
DetPadStride
,
DetPermute
,
DetResize
...
...
@@ -53,13 +54,14 @@ def create_operators(params):
class
UnifiedResize
(
object
):
def
__init__
(
self
,
interpolation
=
None
,
backend
=
"cv2"
):
def
__init__
(
self
,
interpolation
=
None
,
backend
=
"cv2"
,
return_numpy
=
True
):
_cv2_interp_from_str
=
{
'nearest'
:
cv2
.
INTER_NEAREST
,
'bilinear'
:
cv2
.
INTER_LINEAR
,
'area'
:
cv2
.
INTER_AREA
,
'bicubic'
:
cv2
.
INTER_CUBIC
,
'lanczos'
:
cv2
.
INTER_LANCZOS4
'lanczos'
:
cv2
.
INTER_LANCZOS4
,
'random'
:
(
cv2
.
INTER_LINEAR
,
cv2
.
INTER_CUBIC
)
}
_pil_interp_from_str
=
{
'nearest'
:
Image
.
NEAREST
,
...
...
@@ -67,13 +69,26 @@ class UnifiedResize(object):
'bicubic'
:
Image
.
BICUBIC
,
'box'
:
Image
.
BOX
,
'lanczos'
:
Image
.
LANCZOS
,
'hamming'
:
Image
.
HAMMING
'hamming'
:
Image
.
HAMMING
,
'random'
:
(
Image
.
BILINEAR
,
Image
.
BICUBIC
)
}
def
_pil_resize
(
src
,
size
,
resample
):
pil_img
=
Image
.
fromarray
(
src
)
def
_cv2_resize
(
src
,
size
,
resample
):
if
isinstance
(
resample
,
tuple
):
resample
=
random
.
choice
(
resample
)
return
cv2
.
resize
(
src
,
size
,
interpolation
=
resample
)
def
_pil_resize
(
src
,
size
,
resample
,
return_numpy
=
True
):
if
isinstance
(
resample
,
tuple
):
resample
=
random
.
choice
(
resample
)
if
isinstance
(
src
,
np
.
ndarray
):
pil_img
=
Image
.
fromarray
(
src
)
else
:
pil_img
=
src
pil_img
=
pil_img
.
resize
(
size
,
resample
)
return
np
.
asarray
(
pil_img
)
if
return_numpy
:
return
np
.
asarray
(
pil_img
)
return
pil_img
if
backend
.
lower
()
==
"cv2"
:
if
isinstance
(
interpolation
,
str
):
...
...
@@ -81,11 +96,12 @@ class UnifiedResize(object):
# compatible with opencv < version 4.4.0
elif
interpolation
is
None
:
interpolation
=
cv2
.
INTER_LINEAR
self
.
resize_func
=
partial
(
cv2
.
resize
,
interpolation
=
interpolation
)
self
.
resize_func
=
partial
(
_cv2_resize
,
resample
=
interpolation
)
elif
backend
.
lower
()
==
"pil"
:
if
isinstance
(
interpolation
,
str
):
interpolation
=
_pil_interp_from_str
[
interpolation
.
lower
()]
self
.
resize_func
=
partial
(
_pil_resize
,
resample
=
interpolation
)
self
.
resize_func
=
partial
(
_pil_resize
,
resample
=
interpolation
,
return_numpy
=
return_numpy
)
else
:
logger
.
warning
(
f
"The backend of Resize only support
\"
cv2
\"
or
\"
PIL
\"
.
\"
f
{
backend
}
\"
is unavailable. Use
\"
cv2
\"
instead."
...
...
@@ -93,6 +109,8 @@ class UnifiedResize(object):
self
.
resize_func
=
cv2
.
resize
def
__call__
(
self
,
src
,
size
):
if
isinstance
(
size
,
list
):
size
=
tuple
(
size
)
return
self
.
resize_func
(
src
,
size
)
...
...
@@ -137,7 +155,8 @@ class ResizeImage(object):
size
=
None
,
resize_short
=
None
,
interpolation
=
None
,
backend
=
"cv2"
):
backend
=
"cv2"
,
return_numpy
=
True
):
if
resize_short
is
not
None
and
resize_short
>
0
:
self
.
resize_short
=
resize_short
self
.
w
=
None
...
...
@@ -151,10 +170,18 @@ class ResizeImage(object):
'both 'size' and 'resize_short' are None"
)
self
.
_resize_func
=
UnifiedResize
(
interpolation
=
interpolation
,
backend
=
backend
)
interpolation
=
interpolation
,
backend
=
backend
,
return_numpy
=
return_numpy
)
def
__call__
(
self
,
img
):
img_h
,
img_w
=
img
.
shape
[:
2
]
if
isinstance
(
img
,
np
.
ndarray
):
# numpy input
img_h
,
img_w
=
img
.
shape
[:
2
]
else
:
# PIL image input
img_w
,
img_h
=
img
.
size
if
self
.
resize_short
is
not
None
:
percent
=
float
(
self
.
resize_short
)
/
min
(
img_w
,
img_h
)
w
=
int
(
round
(
img_w
*
percent
))
...
...
docs/en/algorithm_introduction/reid.md
0 → 100644
浏览文件 @
d8c1d824
此差异已折叠。
点击以展开。
docs/images/reid/reid_overview.jpg
0 → 100644
浏览文件 @
d8c1d824
87.4 KB
docs/images/reid/strong-baseline.jpg
0 → 100644
浏览文件 @
d8c1d824
265.0 KB
docs/zh_CN/algorithm_introduction/reid.md
0 → 100644
浏览文件 @
d8c1d824
此差异已折叠。
点击以展开。
ppcls/configs/reid/strong_baseline/baseline.yaml
浏览文件 @
d8c1d824
...
...
@@ -64,42 +64,42 @@ Optimizer:
by_epoch
:
True
last_epoch
:
0
regularizer
:
name
:
'
L2'
name
:
"
L2"
coeff
:
0.0005
# data loader for train and eval
DataLoader
:
Train
:
dataset
:
name
:
"
Market1501"
image_root
:
"
./dataset/"
cls_label_path
:
"
bounding_box_train"
backend
:
"
pil"
transform_ops
:
-
ResizeImage
:
size
:
[
128
,
256
]
return_numpy
:
False
interpolation
:
'
bilinear'
backend
:
"
pil"
-
RandFlipImage
:
flip_code
:
1
-
Pad
:
padding
:
10
-
RandCropImageV2
:
size
:
[
128
,
256
]
-
ToTensor
:
-
Normalize
:
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
name
:
"
Market1501"
image_root
:
"
./dataset/"
cls_label_path
:
"
bounding_box_train"
backend
:
"
pil"
transform_ops
:
-
ResizeImage
:
size
:
[
128
,
256
]
return_numpy
:
False
interpolation
:
"
bilinear"
backend
:
"
pil"
-
RandFlipImage
:
flip_code
:
1
-
Pad
:
padding
:
10
-
RandCropImageV2
:
size
:
[
128
,
256
]
-
ToTensor
:
-
Normalize
:
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
sampler
:
name
:
DistributedRandomIdentitySampler
batch_size
:
64
num_instances
:
4
drop_last
:
False
shuffle
:
True
name
:
DistributedRandomIdentitySampler
batch_size
:
64
num_instances
:
4
drop_last
:
False
shuffle
:
True
loader
:
num_workers
:
4
use_shared_memory
:
True
num_workers
:
4
use_shared_memory
:
True
Eval
:
Query
:
dataset
:
...
...
@@ -111,7 +111,7 @@ DataLoader:
-
ResizeImage
:
size
:
[
128
,
256
]
return_numpy
:
False
interpolation
:
'
bilinear'
interpolation
:
"
bilinear"
backend
:
"
pil"
-
ToTensor
:
-
Normalize
:
...
...
@@ -136,7 +136,7 @@ DataLoader:
-
ResizeImage
:
size
:
[
128
,
256
]
return_numpy
:
False
interpolation
:
'
bilinear'
interpolation
:
"
bilinear"
backend
:
"
pil"
-
ToTensor
:
-
Normalize
:
...
...
ppcls/configs/reid/strong_baseline/softmax_triplet.yaml
浏览文件 @
d8c1d824
...
...
@@ -76,48 +76,48 @@ Optimizer:
by_epoch
:
True
last_epoch
:
0
regularizer
:
name
:
'
L2'
name
:
"
L2"
coeff
:
0.0005
# data loader for train and eval
DataLoader
:
Train
:
dataset
:
name
:
"
Market1501"
image_root
:
"
./dataset/"
cls_label_path
:
"
bounding_box_train"
backend
:
"
pil"
transform_ops
:
-
ResizeImage
:
size
:
[
128
,
256
]
return_numpy
:
False
interpolation
:
'
bilinear'
backend
:
"
pil"
-
RandFlipImage
:
flip_code
:
1
-
Pad
:
padding
:
10
-
RandCropImageV2
:
size
:
[
128
,
256
]
-
ToTensor
:
-
Normalize
:
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
-
RandomErasing
:
EPSILON
:
0.5
sl
:
0.02
sh
:
0.4
r1
:
0.3
mean
:
[
0.485
,
0.456
,
0.406
]
name
:
"
Market1501"
image_root
:
"
./dataset/"
cls_label_path
:
"
bounding_box_train"
backend
:
"
pil"
transform_ops
:
-
ResizeImage
:
size
:
[
128
,
256
]
return_numpy
:
False
interpolation
:
"
bilinear"
backend
:
"
pil"
-
RandFlipImage
:
flip_code
:
1
-
Pad
:
padding
:
10
-
RandCropImageV2
:
size
:
[
128
,
256
]
-
ToTensor
:
-
Normalize
:
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
-
RandomErasing
:
EPSILON
:
0.5
sl
:
0.02
sh
:
0.4
r1
:
0.3
mean
:
[
0.485
,
0.456
,
0.406
]
sampler
:
name
:
DistributedRandomIdentitySampler
batch_size
:
64
num_instances
:
4
drop_last
:
False
shuffle
:
True
name
:
DistributedRandomIdentitySampler
batch_size
:
64
num_instances
:
4
drop_last
:
False
shuffle
:
True
loader
:
num_workers
:
4
use_shared_memory
:
True
num_workers
:
4
use_shared_memory
:
True
Eval
:
Query
:
dataset
:
...
...
@@ -129,7 +129,7 @@ DataLoader:
-
ResizeImage
:
size
:
[
128
,
256
]
return_numpy
:
False
interpolation
:
'
bilinear'
interpolation
:
"
bilinear"
backend
:
"
pil"
-
ToTensor
:
-
Normalize
:
...
...
@@ -154,7 +154,7 @@ DataLoader:
-
ResizeImage
:
size
:
[
128
,
256
]
return_numpy
:
False
interpolation
:
'
bilinear'
interpolation
:
"
bilinear"
backend
:
"
pil"
-
ToTensor
:
-
Normalize
:
...
...
ppcls/configs/reid/strong_baseline/softmax_triplet_with_center.yaml
浏览文件 @
d8c1d824
...
...
@@ -82,7 +82,7 @@ Optimizer:
by_epoch
:
True
last_epoch
:
0
regularizer
:
name
:
'
L2'
name
:
"
L2"
coeff
:
0.0005
-
SGD
:
scope
:
CenterLoss
...
...
@@ -94,41 +94,41 @@ Optimizer:
DataLoader
:
Train
:
dataset
:
name
:
"
Market1501"
image_root
:
"
./dataset/"
cls_label_path
:
"
bounding_box_train"
backend
:
"
pil"
transform_ops
:
-
ResizeImage
:
size
:
[
128
,
256
]
return_numpy
:
False
interpolation
:
'
bilinear'
backend
:
"
pil"
-
RandFlipImage
:
flip_code
:
1
-
Pad
:
padding
:
10
-
RandCropImageV2
:
size
:
[
128
,
256
]
-
ToTensor
:
-
Normalize
:
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
-
RandomErasing
:
EPSILON
:
0.5
sl
:
0.02
sh
:
0.4
r1
:
0.3
mean
:
[
0.485
,
0.456
,
0.406
]
name
:
"
Market1501"
image_root
:
"
./dataset/"
cls_label_path
:
"
bounding_box_train"
backend
:
"
pil"
transform_ops
:
-
ResizeImage
:
size
:
[
128
,
256
]
return_numpy
:
False
interpolation
:
"
bilinear"
backend
:
"
pil"
-
RandFlipImage
:
flip_code
:
1
-
Pad
:
padding
:
10
-
RandCropImageV2
:
size
:
[
128
,
256
]
-
ToTensor
:
-
Normalize
:
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
-
RandomErasing
:
EPSILON
:
0.5
sl
:
0.02
sh
:
0.4
r1
:
0.3
mean
:
[
0.485
,
0.456
,
0.406
]
sampler
:
name
:
DistributedRandomIdentitySampler
batch_size
:
64
num_instances
:
4
drop_last
:
False
shuffle
:
True
name
:
DistributedRandomIdentitySampler
batch_size
:
64
num_instances
:
4
drop_last
:
False
shuffle
:
True
loader
:
num_workers
:
4
use_shared_memory
:
True
num_workers
:
4
use_shared_memory
:
True
Eval
:
Query
:
dataset
:
...
...
@@ -140,7 +140,7 @@ DataLoader:
-
ResizeImage
:
size
:
[
128
,
256
]
return_numpy
:
False
interpolation
:
'
bilinear'
interpolation
:
"
bilinear"
backend
:
"
pil"
-
ToTensor
:
-
Normalize
:
...
...
@@ -165,7 +165,7 @@ DataLoader:
-
ResizeImage
:
size
:
[
128
,
256
]
return_numpy
:
False
interpolation
:
'
bilinear'
interpolation
:
"
bilinear"
backend
:
"
pil"
-
ToTensor
:
-
Normalize
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录