Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
e41f2a8f
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
1 年多 前同步成功
通知
116
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看板
提交
e41f2a8f
编写于
1月 03, 2023
作者:
G
gaotingquan
提交者:
Tingquan Gao
1月 06, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support PCALighting
上级
963dcb9c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
3 deletion
+31
-3
ppcls/data/preprocess/__init__.py
ppcls/data/preprocess/__init__.py
+1
-0
ppcls/data/preprocess/ops/operators.py
ppcls/data/preprocess/ops/operators.py
+30
-3
未找到文件。
ppcls/data/preprocess/__init__.py
浏览文件 @
e41f2a8f
...
...
@@ -45,6 +45,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
PCALighting
from
.ops.operators
import
format_data
from
paddle.vision.transforms
import
Pad
as
Pad_paddle_vision
...
...
ppcls/data/preprocess/ops/operators.py
浏览文件 @
e41f2a8f
...
...
@@ -721,8 +721,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
:
...
...
@@ -868,4 +868,31 @@ class RandomGrayscale(object):
return
img
def
__repr__
(
self
):
return
self
.
__class__
.
__name__
+
'()'
\ No newline at end of file
return
self
.
__class__
.
__name__
+
'()'
class
PCALighting
(
object
):
"""Lighting noise(AlexNet - style PCA - based noise)"""
def
__init__
(
self
):
self
.
alphastd
=
0.1
self
.
eigval
=
[
0.2175
,
0.0188
,
0.0045
]
self
.
eigvec
=
[
[
-
0.5675
,
0.7192
,
0.4009
],
[
-
0.5808
,
-
0.0045
,
-
0.8140
],
[
-
0.5836
,
-
0.6948
,
0.4203
],
]
self
.
eigval
=
np
.
array
(
self
.
eigval
).
astype
(
np
.
float32
)
self
.
eigvec
=
np
.
array
(
self
.
eigvec
).
astype
(
np
.
float32
)
def
__call__
(
self
,
img
):
if
self
.
alphastd
==
0
:
return
img
img
=
img
.
transpose
((
2
,
0
,
1
))
alpha
=
np
.
random
.
normal
(
0
,
self
.
alphastd
,
size
=
(
3
)).
astype
(
np
.
float32
)
rgb
=
self
.
eigvec
*
np
.
broadcast_to
(
alpha
.
reshape
(
1
,
3
),
(
3
,
3
))
*
np
.
broadcast_to
(
self
.
eigval
.
reshape
(
1
,
3
),
(
3
,
3
))
rgb
=
rgb
.
sum
(
1
).
squeeze
()
img
=
img
+
rgb
.
reshape
(
3
,
1
,
1
)
return
img
.
transpose
((
1
,
2
,
0
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录