Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
曾经的那一瞬间
Models
提交
373eeb61
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,发现更多精彩内容 >>
提交
373eeb61
编写于
11月 13, 2022
作者:
S
sineeli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test case for missing object annotation
上级
b054d2eb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
90 addition
and
1 deletion
+90
-1
official/vision/data/create_coco_tf_record.py
official/vision/data/create_coco_tf_record.py
+6
-1
official/vision/data/tfrecord_lib_test.py
official/vision/data/tfrecord_lib_test.py
+84
-0
未找到文件。
official/vision/data/create_coco_tf_record.py
浏览文件 @
373eeb61
...
...
@@ -319,6 +319,7 @@ def create_tf_example(image,
feature_dict
=
tfrecord_lib
.
image_info_to_feature_dict
(
image_height
,
image_width
,
filename
,
image_id
,
encoded_jpg
,
'jpg'
)
feature_dict_len
=
len
(
feature_dict
)
num_annotations_skipped
=
0
if
bbox_annotations
:
box_feature_dict
,
num_skipped
=
bbox_annotations_to_feature_dict
(
...
...
@@ -352,7 +353,11 @@ def create_tf_example(image,
encoded_panoptic_masks
[
'instance_mask'
])
})
example
=
tf
.
train
.
Example
(
features
=
tf
.
train
.
Features
(
feature
=
feature_dict
))
if
feature_dict_len
==
len
(
feature_dict
):
example
=
None
else
:
example
=
tf
.
train
.
Example
(
features
=
tf
.
train
.
Features
(
feature
=
feature_dict
))
return
example
,
num_annotations_skipped
...
...
official/vision/data/tfrecord_lib_test.py
浏览文件 @
373eeb61
...
...
@@ -21,6 +21,7 @@ from absl.testing import parameterized
import
tensorflow
as
tf
from
official.vision.data
import
tfrecord_lib
from
official.vision.data.create_coco_tf_record
import
generate_annotations
,
create_tf_example
FLAGS
=
flags
.
FLAGS
...
...
@@ -87,7 +88,90 @@ class TfrecordLibTest(parameterized.TestCase):
proto
=
tfrecord_lib
.
convert_to_feature
([
b
'123'
,
b
'456'
])
self
.
assertSequenceAlmostEqual
(
proto
.
bytes_list
.
value
,
[
b
'123'
,
b
'456'
])
def
test_obj_annotation_tf_example
(
self
):
images
=
[
{
"id"
:
0
,
"file_name"
:
"example1.jpg"
,
"height"
:
512
,
"width"
:
512
,
},
{
"id"
:
1
,
"file_name"
:
"example2.jpg"
,
"height"
:
512
,
"width"
:
512
,
}
]
img_to_obj_annotation
=
{
0
:
[
{
"id"
:
0
,
"image_id"
:
0
,
"category_id"
:
1
,
"bbox"
:
[
3
,
1
,
511
,
510
],
"area"
:
260610.00
,
"segmentation"
:
[],
"iscrowd"
:
0
}
],
1
:
[
{
"id"
:
1
,
"image_id"
:
1
,
"category_id"
:
1
,
"bbox"
:
[
1
,
1
,
100
,
150
],
"area"
:
15000.00
,
"segmentation"
:
[],
"iscrowd"
:
0
}
]
}
id_to_name_map
=
{
0
:
'Super-Class'
,
1
:
'Class-1'
}
temp_dir
=
FLAGS
.
test_tmpdir
image_dir
=
os
.
path
.
join
(
temp_dir
,
'data'
)
if
not
os
.
path
.
exists
(
image_dir
):
os
.
mkdir
(
image_dir
)
for
image
in
images
:
image_path
=
os
.
path
.
join
(
image_dir
,
image
[
'file_name'
])
tf
.
keras
.
utils
.
save_img
(
image_path
,
tf
.
ones
(
shape
=
(
image
[
'height'
],
image
[
'width'
],
3
)).
numpy
())
output_path
=
os
.
path
.
join
(
image_dir
,
'train'
)
coco_annotations_iter
=
generate_annotations
(
images
=
images
,
image_dirs
=
[
image_dir
],
panoptic_masks_dir
=
None
,
img_to_obj_annotation
=
img_to_obj_annotation
,
img_to_caption_annotation
=
None
,
img_to_panoptic_annotation
=
None
,
is_category_thing
=
None
,
id_to_name_map
=
id_to_name_map
,
include_panoptic_masks
=
False
,
include_masks
=
False
)
tfrecord_lib
.
write_tf_record_dataset
(
output_path
,
coco_annotations_iter
,
create_tf_example
,
1
,
multiple_processes
=
0
)
tfrecord_files
=
tf
.
io
.
gfile
.
glob
(
output_path
+
'*'
)
self
.
assertLen
(
tfrecord_files
,
1
)
ds
=
tf
.
data
.
TFRecordDataset
(
tfrecord_files
)
assertion_count
=
0
for
_
in
ds
:
assertion_count
+=
1
self
.
assertEqual
(
assertion_count
,
1
)
if
__name__
==
'__main__'
:
tf
.
test
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录