Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
27号BigBang
Mask_RCNN
提交
459dbb74
M
Mask_RCNN
项目概览
27号BigBang
/
Mask_RCNN
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Mask_RCNN
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
GitCode(gitcode.net)2024年7月9日维护升级公告
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
459dbb74
编写于
11月 12, 2017
作者:
W
Waleed Abdulla
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove display_detections(). Not used.
上级
677eeb79
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
0 addition
and
58 deletion
+0
-58
visualize.py
visualize.py
+0
-58
未找到文件。
visualize.py
浏览文件 @
459dbb74
...
...
@@ -219,64 +219,6 @@ def draw_box(image, box, color):
return
image
def
display_detections
(
image
,
gt_boxes
,
boxes
,
masks
,
class_ids
,
class_names
,
scores
=
None
):
"""
boxes: [num_instance, (y1, x1, y2, x2, class_id)] in image coordinates.
masks: [num_instances, height, width]
class_ids: [num_instances]
class_names: list of class names of the dataset
scores: (optional) confidence scores for each box
"""
assert
boxes
.
shape
[
0
]
==
masks
.
shape
[
-
1
]
==
class_ids
.
shape
[
0
]
fig
,
ax
=
plt
.
subplots
(
1
,
figsize
=
(
20
,
20
))
N
=
boxes
.
shape
[
0
]
# number of instances
colors
=
random_colors
(
N
)
# Show area outside image boundaries.
height
,
width
=
image
.
shape
[:
2
]
ax
.
set_ylim
(
height
+
10
,
-
10
)
ax
.
set_xlim
(
-
10
,
width
+
10
)
ax
.
axis
(
'off'
)
masked_image
=
image
.
astype
(
np
.
uint32
).
copy
()
for
i
in
range
(
N
):
color
=
colors
[
i
]
# Bounding box
if
not
np
.
any
(
boxes
[
i
]):
# Skip this instance. Has no bbox. Likely lost in image cropping.
continue
y1
,
x1
,
y2
,
x2
=
boxes
[
i
]
p
=
patches
.
Rectangle
((
x1
,
y1
),
x2
-
x1
,
y2
-
y1
,
linewidth
=
2
,
alpha
=
0.7
,
linestyle
=
"dashed"
,
edgecolor
=
color
,
facecolor
=
'none'
)
ax
.
add_patch
(
p
)
# Label
class_id
=
class_ids
[
i
]
score
=
scores
[
i
]
if
scores
is
not
None
else
None
label
=
class_names
[
class_id
]
x
=
random
.
randint
(
x1
,
(
x1
+
x2
)
//
2
)
ax
.
text
(
x1
,
y1
+
8
,
"{} {:.3f}"
.
format
(
label
,
score
)
if
score
else
label
,
color
=
'w'
,
size
=
11
,
backgroundcolor
=
"none"
)
# Mask
mask
=
masks
[:,:,
i
]
masked_image
=
apply_mask
(
masked_image
,
mask
,
color
)
# Mask Polygon
# Pad the mask to ensure proper polygons for mask that touch image edges.
padded_mask
=
np
.
zeros
((
mask
.
shape
[
0
]
+
2
,
mask
.
shape
[
1
]
+
2
),
dtype
=
np
.
uint8
)
padded_mask
[
1
:
-
1
,
1
:
-
1
]
=
mask
contours
=
find_contours
(
padded_mask
,
0.5
)
for
verts
in
contours
:
# Subtract the padding and flip (y, x) to (x, y)
verts
=
np
.
fliplr
(
verts
)
-
1
p
=
Polygon
(
verts
,
facecolor
=
"none"
,
edgecolor
=
color
)
ax
.
add_patch
(
p
)
return
plt
.
imshow
(
masked_image
.
astype
(
np
.
uint8
))
def
display_top_masks
(
image
,
mask
,
class_ids
,
class_names
,
limit
=
4
):
"""Display the given image and the top few class masks."""
to_display
=
[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录