Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
fix typo in datasets/custom.py.
Modification
Change the docs about
results
fromlist[tuple[torch.Tensor]
tolist[list[torch.Tensor]
The reason why it is
list[list[torch.Tensor]
, notlist[tuple[torch.Tensor]
is listed as follows in parts of Chinese:看一下脱水的
single_gpu_test
代码:也就是说
dataset.pre_eval
返回的result
是tuple[torch.Tensor]
. 不过我们先来看下model
返回的结果.对于 mmseg 来说, model 就是
EncoderDecoder
了, 在 validation 的时候,model(・)
其实就是EncoderDecoder.forward_test(・)
.虽然如上图所示,
forward_test
的调用链条很长, 但其实返回的result
就是simple_test
的返回结果. 而simple_test
的代码如下seg_logit
是(N, C, H, W)
的 Tensorseg_logit.argmax(dim=1)
得到的seg_pred
是(N, H, W)
的 Tensor;seg_pred = list(seg_pred)
得到的seg_pred
是list[np.ndarray]
.因此,
model(・)
也就是EncoderDecoder.forward_test(・)
返回的result
是list[np.ndarray]
. 接下来要看一下dataset.pre_eval
的代码.pre_eval
这个函数的功能本身就是 Collect eval result from each iteration. 从下面的代码可以看到, 返回的pre_eval_results
还是一个list[torch.Tensor]
.intersect_and_union
这个函数会将 np.ndarray 的输入变为 torch.Tensor 再计算, 所以返回的结果是 torch.Tensor, 因此, 返回的pre_eval_results
就是list[torch.Tensor]
.BC-breaking (Optional)
Does the modification introduce changes that break the backward-compatibility of the downstream repos?
No. It is only a modification to the comments.