Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
曾经的那一瞬间
Models
提交
3b4caa8f
M
Models
项目概览
曾经的那一瞬间
/
Models
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3b4caa8f
编写于
4月 19, 2023
作者:
A
A. Unique TensorFlower
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Internal change
PiperOrigin-RevId: 525618180
上级
e545ea9b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
11 deletion
+34
-11
official/vision/dataloaders/classification_input.py
official/vision/dataloaders/classification_input.py
+34
-11
未找到文件。
official/vision/dataloaders/classification_input.py
浏览文件 @
3b4caa8f
...
...
@@ -82,7 +82,8 @@ class Parser(parser.Parser):
output_size: `Tensor` or `list` for [height, width] of output image. The
output_size should be divided by the largest feature stride 2^max_level.
num_classes: `float`, number of classes.
image_field_key: `str`, the key name to encoded image in tf.Example.
image_field_key: `str`, the key name to encoded image or decoded image
matrix in tf.Example.
label_field_key: `str`, the key name to label in tf.Example.
decode_jpeg_only: `bool`, if True, only JPEG format is decoded, this is
faster than decoding other types. Default is True.
...
...
@@ -185,8 +186,15 @@ class Parser(parser.Parser):
def
_parse_train_image
(
self
,
decoded_tensors
):
"""Parses image data for training."""
image_bytes
=
decoded_tensors
[
self
.
_image_field_key
]
if
self
.
_decode_jpeg_only
and
self
.
_aug_crop
:
require_decoding
=
(
not
tf
.
is_tensor
(
image_bytes
)
or
image_bytes
.
dtype
==
tf
.
dtypes
.
string
)
if
(
require_decoding
and
self
.
_decode_jpeg_only
and
self
.
_aug_crop
):
image_shape
=
tf
.
image
.
extract_jpeg_shape
(
image_bytes
)
# Crops image.
...
...
@@ -197,9 +205,13 @@ class Parser(parser.Parser):
lambda
:
preprocess_ops
.
center_crop_image_v2
(
image_bytes
,
image_shape
),
lambda
:
cropped_image
)
else
:
# Decodes image.
image
=
tf
.
io
.
decode_image
(
image_bytes
,
channels
=
3
)
image
.
set_shape
([
None
,
None
,
3
])
if
require_decoding
:
# Decodes image.
image
=
tf
.
io
.
decode_image
(
image_bytes
,
channels
=
3
)
image
.
set_shape
([
None
,
None
,
3
])
else
:
# Already decoded image matrix
image
=
image_bytes
# Crops image.
if
self
.
_aug_crop
:
...
...
@@ -252,17 +264,28 @@ class Parser(parser.Parser):
def
_parse_eval_image
(
self
,
decoded_tensors
):
"""Parses image data for evaluation."""
image_bytes
=
decoded_tensors
[
self
.
_image_field_key
]
if
self
.
_decode_jpeg_only
and
self
.
_aug_crop
:
require_decoding
=
(
not
tf
.
is_tensor
(
image_bytes
)
or
image_bytes
.
dtype
==
tf
.
dtypes
.
string
)
if
(
require_decoding
and
self
.
_decode_jpeg_only
and
self
.
_aug_crop
):
image_shape
=
tf
.
image
.
extract_jpeg_shape
(
image_bytes
)
# Center crops.
image
=
preprocess_ops
.
center_crop_image_v2
(
image_bytes
,
image_shape
,
self
.
_center_crop_fraction
)
else
:
# Decodes image.
image
=
tf
.
io
.
decode_image
(
image_bytes
,
channels
=
3
)
image
.
set_shape
([
None
,
None
,
3
])
if
require_decoding
:
# Decodes image.
image
=
tf
.
io
.
decode_image
(
image_bytes
,
channels
=
3
)
image
.
set_shape
([
None
,
None
,
3
])
else
:
# Already decoded image matrix
image
=
image_bytes
# Center crops.
if
self
.
_aug_crop
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录