Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
08320527
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看板
提交
08320527
编写于
9月 29, 2022
作者:
C
cuicheng01
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add clarity_assessment code
上级
b3ab418e
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
185 addition
and
2 deletion
+185
-2
ppcls/configs/PULC/clarity_assessment/PPLCNet_x1_0.yaml
ppcls/configs/PULC/clarity_assessment/PPLCNet_x1_0.yaml
+131
-0
ppcls/data/preprocess/__init__.py
ppcls/data/preprocess/__init__.py
+1
-0
ppcls/data/preprocess/ops/operators.py
ppcls/data/preprocess/ops/operators.py
+53
-2
未找到文件。
ppcls/configs/PULC/clarity_assessment/PPLCNet_x1_0.yaml
0 → 100644
浏览文件 @
08320527
# global configs
Global
:
checkpoints
:
null
pretrained_model
:
null
output_dir
:
./output/
device
:
gpu
save_interval
:
10
eval_during_train
:
True
eval_interval
:
1
epochs
:
20
print_batch_step
:
10
use_visualdl
:
False
# used for static mode and model export
image_shape
:
[
3
,
224
,
224
]
save_inference_dir
:
./inference
# model architecture
Arch
:
name
:
PPLCNet_x1_0
pretrained
:
True
use_ssld
:
True
class_num
:
2
use_last_conv
:
False
# loss function config for traing/eval process
Loss
:
Train
:
-
CELoss
:
weight
:
1.0
epsilon
:
0.1
Eval
:
-
CELoss
:
weight
:
1.0
Optimizer
:
name
:
Momentum
momentum
:
0.9
lr
:
name
:
Cosine
learning_rate
:
0.14
warmup_epoch
:
5
regularizer
:
name
:
'
L2'
coeff
:
0.00003
# data loader for train and eval
DataLoader
:
Train
:
dataset
:
name
:
CustomLabelDataset
image_root
:
./dataset/
sample_list_path
:
./dataset/ImageNet_OCR_det.txt
label_key
:
blur_image
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
RandCropImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
-
BlurImage
:
sampler
:
name
:
DistributedBatchSampler
batch_size
:
256
drop_last
:
False
shuffle
:
True
loader
:
num_workers
:
12
use_shared_memory
:
True
Eval
:
dataset
:
name
:
ImageNetDataset
image_root
:
./dataset/blur/
cls_label_path
:
./dataset/blur/val_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
:
64
drop_last
:
False
shuffle
:
False
loader
:
num_workers
:
4
use_shared_memory
:
True
Infer
:
infer_imgs
:
./test_img/
batch_size
:
1
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
:
Topk
topk
:
1
Metric
:
Train
:
-
TopkAcc
:
topk
:
[
1
]
Eval
:
-
TopkAcc
:
topk
:
[
1
]
ppcls/data/preprocess/__init__.py
浏览文件 @
08320527
...
...
@@ -41,6 +41,7 @@ from ppcls.data.preprocess.ops.operators import RandomCropImage
from
ppcls.data.preprocess.ops.operators
import
RandomRotation
from
ppcls.data.preprocess.ops.operators
import
Padv2
from
ppcls.data.preprocess.ops.operators
import
RandomRot90
from
ppcls.data.preprocess.ops.operators
import
BlurImage
from
.ops.operators
import
format_data
from
ppcls.data.preprocess.batch_ops.batch_operators
import
MixupOperator
,
CutmixOperator
,
OpSampler
,
FmixOperator
...
...
ppcls/data/preprocess/ops/operators.py
浏览文件 @
08320527
...
...
@@ -718,8 +718,8 @@ class Pad(object):
# Process fill color for affine transforms
major_found
,
minor_found
=
(
int
(
v
)
for
v
in
PILLOW_VERSION
.
split
(
'.'
)[:
2
])
major_required
,
minor_required
=
(
int
(
v
)
for
v
in
min_pil_version
.
split
(
'.'
)[:
2
])
major_required
,
minor_required
=
(
int
(
v
)
for
v
in
min_pil_version
.
split
(
'.'
)[:
2
])
if
major_found
<
major_required
or
(
major_found
==
major_required
and
minor_found
<
minor_required
):
if
fill
is
None
:
...
...
@@ -781,3 +781,54 @@ class RandomRot90(object):
if
orientation
:
img
=
np
.
rot90
(
img
,
orientation
)
return
{
"img"
:
img
,
"random_rot90_orientation"
:
orientation
}
class
BlurImage
(
object
):
"""BlurImage
"""
def
__init__
(
self
,
ratio
=
0.5
,
motion_max_ksize
=
12
,
motion_max_angle
=
45
,
gaussian_max_ksize
=
12
):
self
.
ratio
=
ratio
self
.
motion_max_ksize
=
motion_max_ksize
self
.
motion_max_angle
=
motion_max_angle
self
.
gaussian_max_ksize
=
gaussian_max_ksize
def
_gaussian_blur
(
self
,
img
,
max_ksize
=
12
):
ksize
=
(
np
.
random
.
choice
(
np
.
arange
(
5
,
max_ksize
,
2
)),
np
.
random
.
choice
(
np
.
arange
(
5
,
max_ksize
,
2
)))
img
=
cv2
.
GaussianBlur
(
img
,
ksize
,
0
)
return
img
def
_motion_blur
(
self
,
img
,
max_ksize
=
12
,
max_angle
=
45
):
degree
=
np
.
random
.
choice
(
np
.
arange
(
5
,
max_ksize
,
2
))
angle
=
np
.
random
.
choice
(
np
.
arange
(
-
1
*
max_angle
,
max_angle
))
M
=
cv2
.
getRotationMatrix2D
((
degree
/
2
,
degree
/
2
),
angle
,
1
)
motion_blur_kernel
=
np
.
diag
(
np
.
ones
(
degree
))
motion_blur_kernel
=
cv2
.
warpAffine
(
motion_blur_kernel
,
M
,
(
degree
,
degree
))
motion_blur_kernel
=
motion_blur_kernel
/
degree
blurred
=
cv2
.
filter2D
(
img
,
-
1
,
motion_blur_kernel
)
cv2
.
normalize
(
blurred
,
blurred
,
0
,
255
,
cv2
.
NORM_MINMAX
)
img
=
np
.
array
(
blurred
,
dtype
=
np
.
uint8
)
return
img
@
format_data
def
__call__
(
self
,
img
):
if
random
.
random
()
>
self
.
ratio
:
label
=
0
else
:
method
=
random
.
choice
([
"gaussian"
,
"motion"
])
if
method
==
"gaussian"
:
img
=
self
.
_gaussian_blur
(
img
,
self
.
gaussian_max_ksize
)
else
:
img
=
self
.
_motion_blur
(
img
,
self
.
motion_max_ksize
,
self
.
motion_max_angle
)
label
=
1
return
{
"img"
:
img
,
"blur_image"
:
label
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录