Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
baa1f663
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
baa1f663
编写于
11月 23, 2022
作者:
V
Vvsmile
提交者:
GitHub
11月 23, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove API: mean_iou (#47971)
remove mean_iou which is not used in paddle 2.0
上级
b7d3143f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
0 addition
and
93 deletion
+0
-93
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+0
-68
python/paddle/fluid/tests/unittests/test_layers.py
python/paddle/fluid/tests/unittests/test_layers.py
+0
-7
python/paddle/fluid/tests/unittests/test_mean_iou.py
python/paddle/fluid/tests/unittests/test_mean_iou.py
+0
-18
未找到文件。
python/paddle/fluid/layers/nn.py
浏览文件 @
baa1f663
...
...
@@ -114,7 +114,6 @@ __all__ = [
'gather_nd'
,
'scatter'
,
'random_crop'
,
'mean_iou'
,
'relu'
,
'log'
,
'crop_tensor'
,
...
...
@@ -7626,73 +7625,6 @@ def relu(x, name=None):
return
out
def
mean_iou
(
input
,
label
,
num_classes
):
r
"""
Mean Intersection-Over-Union is a common evaluation metric for
semantic image segmentation, which first computes the IOU for each
semantic class and then computes the average over classes.
IOU is defined as follows:
.. math::
IOU = \\frac{true\_positive}{(true\_positive + false\_positive + false\_negative)}.
The predictions are accumulated in a confusion matrix and mean-IOU
is then calculated from it.
Parameters:
input (Tensor): A n-D Tensor of prediction results for semantic labels with type int32 or int64.
label (Tensor): A Tensor of ground truth labels with type int32 or int64.
Its shape should be the same as input.
num_classes (int32): The possible number of labels.
Returns:
Three Tensors.
- mean_iou(Tensor) : A 1-D Tensor representing the mean intersection-over-union with shape [1]. \
Data type is float32.
- out_wrong(Tensor) : A 1-D Tensor with shape [num_classes]. Data type is int32. \
The wrong numbers of each class.
- out_correct(Tensor): A 1-D Tensor with shape [num_classes]. Data type is int32. The correct numbers of each class.
Examples:
.. code-block:: python
import paddle
iou_shape = [64, 32, 32]
num_classes = 5
predict = paddle.randint(low=0, high=255, shape=iou_shape, dtype='int64')
label = paddle.randint(low=0, high=255, shape=iou_shape, dtype='int64')
mean_iou, out_wrong, out_correct = paddle.metric.mean_iou(predict, label, num_classes)
"""
if
_non_static_mode
():
return
_legacy_C_ops
.
mean_iou
(
input
,
label
,
'num_classes'
,
num_classes
)
helper
=
LayerHelper
(
'mean_iou'
,
**
locals
())
check_variable_and_dtype
(
input
,
'Predictions'
,
[
'int32'
,
'int64'
],
'mean_iou'
)
check_variable_and_dtype
(
label
,
'Labels'
,
[
'int32'
,
'int64'
],
'mean_iou'
)
out_mean_iou
=
helper
.
create_variable_for_type_inference
(
dtype
=
'float32'
)
out_wrong
=
helper
.
create_variable_for_type_inference
(
dtype
=
'int32'
)
out_correct
=
helper
.
create_variable_for_type_inference
(
dtype
=
'int32'
)
helper
.
append_op
(
type
=
"mean_iou"
,
inputs
=
{
"Predictions"
:
input
,
"Labels"
:
label
},
outputs
=
{
"OutMeanIou"
:
out_mean_iou
,
"OutWrong"
:
out_wrong
,
"OutCorrect"
:
out_correct
,
},
attrs
=
{
"num_classes"
:
num_classes
},
)
return
out_mean_iou
,
out_wrong
,
out_correct
def
crop_tensor
(
x
,
shape
=
None
,
offsets
=
None
,
name
=
None
):
"""
Crop input into output, as specified by offsets and shape.
...
...
python/paddle/fluid/tests/unittests/test_layers.py
浏览文件 @
baa1f663
...
...
@@ -3476,13 +3476,6 @@ class TestBook(LayerTest):
output
=
layers
.
l2_normalize
(
x
,
axis
=
1
)
return
output
def
make_mean_iou
(
self
):
with
fluid
.
framework
.
_dygraph_place_guard
(
place
=
fluid
.
CPUPlace
()):
x
=
self
.
_get_data
(
name
=
'x'
,
shape
=
[
16
],
dtype
=
'int32'
)
y
=
self
.
_get_data
(
name
=
'label'
,
shape
=
[
16
],
dtype
=
'int32'
)
iou
=
layers
.
mean_iou
(
x
,
y
,
self
.
_high_data_bound
)
return
iou
def
make_argsort
(
self
):
with
program_guard
(
fluid
.
default_main_program
(),
fluid
.
default_startup_program
()
...
...
python/paddle/fluid/tests/unittests/test_mean_iou.py
浏览文件 @
baa1f663
...
...
@@ -15,7 +15,6 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
import
paddle.fluid
as
fluid
def
compute_mean_iou
(
...
...
@@ -140,22 +139,5 @@ class TestCase1(TestMeanIOUOp):
self
.
check_output
(
check_dygraph
=
False
,
check_eager
=
False
)
class
TestMeanIOUOpError
(
unittest
.
TestCase
):
def
test_errors
(
self
):
with
fluid
.
program_guard
(
fluid
.
Program
(),
fluid
.
Program
()):
# The input type of accuracy_op must be Variable.
x1
=
fluid
.
create_lod_tensor
(
np
.
array
([[
-
1
]]),
[[
1
]],
fluid
.
CPUPlace
()
)
y1
=
fluid
.
create_lod_tensor
(
np
.
array
([[
-
1
]]),
[[
1
]],
fluid
.
CPUPlace
()
)
self
.
assertRaises
(
TypeError
,
fluid
.
layers
.
mean_iou
,
x1
,
y1
)
# The input dtype of accuracy_op must be float32 or float64.
x2
=
fluid
.
layers
.
data
(
name
=
'x2'
,
shape
=
[
4
],
dtype
=
"float32"
)
y2
=
fluid
.
layers
.
data
(
name
=
'x2'
,
shape
=
[
4
],
dtype
=
"float32"
)
self
.
assertRaises
(
TypeError
,
fluid
.
layers
.
mean_iou
,
x2
,
y2
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录