Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
509f4d77
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看板
提交
509f4d77
编写于
2月 28, 2022
作者:
L
lubin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify the cifar10 dataset format
上级
cef3cb25
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
135 addition
and
97 deletion
+135
-97
ppcls/configs/DeepHash/DCH.yaml
ppcls/configs/DeepHash/DCH.yaml
+44
-8
ppcls/configs/DeepHash/DSHSD.yaml
ppcls/configs/DeepHash/DSHSD.yaml
+44
-8
ppcls/configs/DeepHash/LCDSH.yaml
ppcls/configs/DeepHash/LCDSH.yaml
+44
-8
ppcls/data/__init__.py
ppcls/data/__init__.py
+0
-1
ppcls/data/dataloader/__init__.py
ppcls/data/dataloader/__init__.py
+0
-1
ppcls/data/dataloader/customized_cifar10.py
ppcls/data/dataloader/customized_cifar10.py
+0
-65
ppcls/loss/deephashloss.py
ppcls/loss/deephashloss.py
+1
-1
ppcls/optimizer/optimizer.py
ppcls/optimizer/optimizer.py
+2
-5
未找到文件。
ppcls/configs/DeepHash/DCH.yaml
浏览文件 @
509f4d77
...
...
@@ -62,8 +62,20 @@ Optimizer:
DataLoader
:
Train
:
dataset
:
name
:
CustomizedCifar10
mode
:
'
train'
name
:
ImageNetDataset
image_root
:
./dataset/
cls_label_path
:
./dataset/cifar10-2/train.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
sampler
:
batch_size
:
128
drop_last
:
False
...
...
@@ -74,9 +86,21 @@ DataLoader:
Eval
:
Query
:
dataset
:
name
:
CustomizedCifar10
mode
:
'
test'
dataset
:
name
:
ImageNetDataset
image_root
:
./dataset/
cls_label_path
:
./dataset/cifar10-2/test.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
sampler
:
batch_size
:
128
drop_last
:
False
...
...
@@ -86,9 +110,21 @@ DataLoader:
use_shared_memory
:
True
Gallery
:
dataset
:
name
:
CustomizedCifar10
mode
:
'
train'
dataset
:
name
:
ImageNetDataset
image_root
:
./dataset/
cls_label_path
:
./dataset/cifar10-2/database.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
sampler
:
batch_size
:
128
drop_last
:
False
...
...
ppcls/configs/DeepHash/DSHSD.yaml
浏览文件 @
509f4d77
...
...
@@ -63,8 +63,20 @@ Optimizer:
DataLoader
:
Train
:
dataset
:
name
:
CustomizedCifar10
mode
:
'
train'
name
:
ImageNetDataset
image_root
:
./dataset/
cls_label_path
:
./dataset/cifar10-2/train.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
sampler
:
batch_size
:
128
drop_last
:
False
...
...
@@ -75,9 +87,21 @@ DataLoader:
Eval
:
Query
:
dataset
:
name
:
CustomizedCifar10
mode
:
'
test'
dataset
:
name
:
ImageNetDataset
image_root
:
./dataset/
cls_label_path
:
./dataset/cifar10-2/test.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
sampler
:
batch_size
:
128
drop_last
:
False
...
...
@@ -87,9 +111,21 @@ DataLoader:
use_shared_memory
:
True
Gallery
:
dataset
:
name
:
CustomizedCifar10
mode
:
'
train'
dataset
:
name
:
ImageNetDataset
image_root
:
./dataset/
cls_label_path
:
./dataset/cifar10-2/database.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
sampler
:
batch_size
:
128
drop_last
:
False
...
...
ppcls/configs/DeepHash/LCDSH.yaml
浏览文件 @
509f4d77
...
...
@@ -59,8 +59,20 @@ Optimizer:
DataLoader
:
Train
:
dataset
:
name
:
CustomizedCifar10
mode
:
'
train'
name
:
ImageNetDataset
image_root
:
./dataset/
cls_label_path
:
./dataset/cifar10-2/train.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
sampler
:
batch_size
:
128
drop_last
:
False
...
...
@@ -71,9 +83,21 @@ DataLoader:
Eval
:
Query
:
dataset
:
name
:
CustomizedCifar10
mode
:
'
test'
dataset
:
name
:
ImageNetDataset
image_root
:
./dataset/
cls_label_path
:
./dataset/cifar10-2/test.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
sampler
:
batch_size
:
128
drop_last
:
False
...
...
@@ -83,9 +107,21 @@ DataLoader:
use_shared_memory
:
True
Gallery
:
dataset
:
name
:
CustomizedCifar10
mode
:
'
train'
dataset
:
name
:
ImageNetDataset
image_root
:
./dataset/
cls_label_path
:
./dataset/cifar10-2/database.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
sampler
:
batch_size
:
128
drop_last
:
False
...
...
ppcls/data/__init__.py
浏览文件 @
509f4d77
...
...
@@ -28,7 +28,6 @@ from ppcls.data.dataloader.vehicle_dataset import CompCars, VeriWild
from
ppcls.data.dataloader.logo_dataset
import
LogoDataset
from
ppcls.data.dataloader.icartoon_dataset
import
ICartoonDataset
from
ppcls.data.dataloader.mix_dataset
import
MixDataset
from
ppcls.data.dataloader.customized_cifar10
import
CustomizedCifar10
# sampler
from
ppcls.data.dataloader.DistributedRandomIdentitySampler
import
DistributedRandomIdentitySampler
...
...
ppcls/data/dataloader/__init__.py
浏览文件 @
509f4d77
...
...
@@ -4,7 +4,6 @@ from ppcls.data.dataloader.common_dataset import create_operators
from
ppcls.data.dataloader.vehicle_dataset
import
CompCars
,
VeriWild
from
ppcls.data.dataloader.logo_dataset
import
LogoDataset
from
ppcls.data.dataloader.icartoon_dataset
import
ICartoonDataset
from
ppcls.data.dataloader.customized_cifar10
import
CustomizedCifar10
from
ppcls.data.dataloader.mix_dataset
import
MixDataset
from
ppcls.data.dataloader.mix_sampler
import
MixSampler
from
ppcls.data.dataloader.pk_sampler
import
PKSampler
ppcls/data/dataloader/customized_cifar10.py
已删除
100644 → 0
浏览文件 @
cef3cb25
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
paddle
from
paddle.vision.datasets
import
Cifar10
from
paddle.vision
import
transforms
from
paddle.dataset.common
import
_check_exists_and_download
import
numpy
as
np
import
os
from
PIL
import
Image
class
CustomizedCifar10
(
Cifar10
):
def
__init__
(
self
,
data_file
=
None
,
mode
=
'train'
,
download
=
True
,
backend
=
None
):
assert
mode
.
lower
()
in
[
'train'
,
'test'
],
\
"mode should be 'train', 'test', but got {}"
.
format
(
mode
)
self
.
mode
=
mode
.
lower
()
if
backend
is
None
:
backend
=
paddle
.
vision
.
get_image_backend
()
if
backend
not
in
[
'pil'
,
'cv2'
]:
raise
ValueError
(
"Expected backend are one of ['pil', 'cv2'], but got {}"
.
format
(
backend
))
self
.
backend
=
backend
self
.
_init_url_md5_flag
()
self
.
data_file
=
data_file
if
self
.
data_file
is
None
:
assert
download
,
"data_file is not set and downloading automatically is disabled"
self
.
data_file
=
_check_exists_and_download
(
data_file
,
self
.
data_url
,
self
.
data_md5
,
'cifar'
,
download
)
self
.
transform
=
transforms
.
Compose
([
transforms
.
Resize
(
224
),
transforms
.
ToTensor
(),
transforms
.
Normalize
([
0.485
,
0.456
,
0.406
],
[
0.229
,
0.224
,
0.225
])
])
self
.
_load_data
()
self
.
dtype
=
paddle
.
get_default_dtype
()
def
__getitem__
(
self
,
index
):
img
,
target
=
self
.
data
[
index
]
img
=
np
.
reshape
(
img
,
[
3
,
32
,
32
])
img
=
img
.
transpose
([
1
,
2
,
0
]).
astype
(
"uint8"
)
img
=
Image
.
fromarray
(
img
)
img
=
self
.
transform
(
img
)
return
(
img
,
target
)
ppcls/loss/deephashloss.py
浏览文件 @
509f4d77
...
...
@@ -132,7 +132,7 @@ class DCHLoss(paddle.nn.Layer):
paddle
.
log
(
1
+
self
.
gamma
/
d_hi_hj
))
all_one
=
paddle
.
ones_like
(
u
,
dtype
=
"float32"
)
quantization_loss
=
paddle
.
log
(
1
+
self
.
d
(
u
.
abs
(),
all_one
)
/
quantization_loss
=
paddle
.
log
(
1
+
self
.
d
istance
(
u
.
abs
(),
all_one
)
/
self
.
gamma
)
loss
=
cauchy_loss
.
mean
()
+
self
.
_lambda
*
quantization_loss
.
mean
()
...
...
ppcls/optimizer/optimizer.py
浏览文件 @
509f4d77
...
...
@@ -49,13 +49,11 @@ class SGD(object):
learning_rate
=
0.001
,
weight_decay
=
None
,
grad_clip
=
None
,
name
=
None
,
multi_precision
=
False
):
name
=
None
):
self
.
learning_rate
=
learning_rate
self
.
weight_decay
=
weight_decay
self
.
grad_clip
=
grad_clip
self
.
name
=
name
self
.
multi_precision
=
multi_precision
def
__call__
(
self
,
model_list
):
# model_list is None in static graph
...
...
@@ -65,8 +63,7 @@ class SGD(object):
parameters
=
parameters
,
weight_decay
=
self
.
weight_decay
,
grad_clip
=
self
.
grad_clip
,
name
=
self
.
name
,
multi_precision
=
self
.
multi_precision
)
name
=
self
.
name
)
return
opt
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录