Repository: open-mmlab/mmdetection

Issue:
Raise 'UserWarning' when running ATSS 
Thanks for your error report and we appreciate it a lot.

**Describe the bug**
I am trying to train ATSS on my data, 
System throws error:
>/pytorch/aten/src/ATen/native/IndexingUtils.h:20: UserWarning: indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead.

**Reproduction**

> python3 tools/train.py configs/atss.py

**Environment**

```
sys.platform: linux
CUDA_HOME: /cuda/cuda-10.0/cuda
PyTorch: 1.4.0
PyTorch compiling details: PyTorch built with:
  - GCC 7.3
  - Intel(R) Math Kernel Library Version 2019.0.4 Product Build 20190411 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v0.21.1 (Git Hash 7d2fd500bc78936d1d648ca713b901012f470dbc)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - NNPACK is enabled
  - CUDA Runtime 10.1
  - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60
,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-genc
ode;arch=compute_37,code=compute_37
  - CuDNN 7.6.3
  - Magma 2.5.1
  - Build settings: BLAS=MKL, BUILD_NAMEDTENSOR=OFF, BUILD_TYPE=Release, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidd
en -fopenmp -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -O2 -fPIC -Wno-narrowing -Wall -Wextra -Wno-missing-field-initia
lizers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -
Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stri
ngop-overflow -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-n
ew -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Wno-stringop-overflow, DISABLE_N
UMA=1, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF,
 USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_STATIC_DISPATCH=OFF,

TorchVision: 0.5.0
Python: 3.5.2 (default, Nov 12 2018, 13:43:14) [GCC 5.4.0 20160609]
GPU 0: GeForce RTX 2080 Ti
GCC: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609
CUDA available: True
NVCC: Cuda compilation tools, release 10.0, V10.0.130
MMDetection CUDA Compiler: 10.0
MMCV: 0.3.2
MMDetection Compiler: GCC 5.4
OpenCV: 4.1.1
MMDetection: 1.1.0+51df8a9
```



Discussion:
Thanks for your report, we will fix it in the following days.
Hi @itisianlee ,
Did you meet this warning at the validation stage? I try to reproduce your warning, but I did not see the warning in the training stage.
> Did you meet this warning at the validation stage? I try to reproduce your warning, but I did not see the warning in the training stage.

it's traing stage. 
note: I used my private data .  
so, i want to know if there is a problem in dataset base class?
Actually it might be because I train and evaluate the ATSS on the COCO dataset but met no warnings.
@itisianlee What format is your dataset? COCO-format or VOC-format or something else?
voc，custom format



> 在 2020年3月14日，11:29，Kai Chen <notifications@github.com> 写道：
> 
> format



i met the same warning, however i used the coco dataset in cascade mask r-cnn 

Resolving patch:
diff --git a/mmdet/models/anchor_heads/atss_head.py b/mmdet/models/anchor_heads/atss_head.py
--- a/mmdet/models/anchor_heads/atss_head.py
+++ b/mmdet/models/anchor_heads/atss_head.py
@@ -428,7 +428,7 @@ def atss_target_single(self,
         if not inside_flags.any():
             return (None, ) * 6
         # assign gt and sample anchors
-        anchors = flat_anchors[inside_flags, :]
+        anchors = flat_anchors[inside_flags.type(torch.bool), :]
 
         num_level_anchors_inside = self.get_num_level_anchors_inside(
             num_level_anchors, inside_flags)
@@ -469,6 +469,7 @@ def atss_target_single(self,
 
         # map up to original set of anchors
         if unmap_outputs:
+            inside_flags = inside_flags.type(torch.bool)
             num_total_anchors = flat_anchors.size(0)
             anchors = unmap(anchors, num_total_anchors, inside_flags)
             labels = unmap(labels, num_total_anchors, inside_flags)


Test patch: