facebookresearch / detectron2

Detectron2 is a platform for object detection, segmentation and other visual recognition tasks.
https://detectron2.readthedocs.io/en/latest/
Apache License 2.0
30.34k stars 7.46k forks source link

draw_dataset_dict() runs without error but does not return any bounding boxes #1142

Closed chrisuzokwe closed 4 years ago

chrisuzokwe commented 4 years ago

1. what changes you made (git diff) or what code you wrote

I haven't changed the base code, but my "images" for this set are comprised of rgb layered audio features -- im trying to see if I can bound the different audio segments in a song (verse, chorus, etc.). Not sure if this is the issue either, but I think it's worth noting that the image sizes I'm dealing with are in the order of thousands in terms of pixels.

2. what exact command you run:

for d in random.sample(dataset_dicts, 1):
    img = cv2.imread(d["file_name"])
    print(img.shape)
    visualizer = Visualizer(img[:, :, ::-1], metadata=audio_metadata, scale=1)
    vis = visualizer.draw_dataset_dict(d)
    plt.figure(figsize=(20,20))
    plt.imshow(vis.get_image()[:, :, ::-1])
    plt.axis('off')
    plt.show()
    img = Image.fromarray(vis.get_image()[:, :, ::1])
    img.save('/home/shared/cuzokwe/datasets/SALAMI/test/datatest.png')
    #cv2_imshow(vis.get_image()[:, :, ::-1])

And this is the annotation I'm using (its very long due to the number of segments and the fact that every pixel should be counted in a segmentation)

{
  "file_name": "/home/shared/cuzokwe/datasets/SALAMI/images/3.png",
  "image_id": 3,
  "height": 5958,
  "width": 5958,
  "annotations": [
    {
      "bbox": [
        109.646803,
        109.646803,
        117.382585,
        117.382585
      ],
      "bbox_mode": 0,
      "segmentation": [
        [
          109.646803,
          109.646803,
          109.646803,
          110.646803,
          109.646803,
          111.646803,
          109.646803,
          112.646803,
          109.646803,
          113.646803,
          109.646803,
          114.646803,
          109.646803,
          115.646803,
          109.646803,
          116.646803,
          110.646803,
          109.646803,
          110.646803,
          110.646803,
          110.646803,
          111.646803,
          110.646803,
          112.646803,
          110.646803,
          113.646803,
          110.646803,
          114.646803,
          110.646803,
          115.646803,
          110.646803,
          116.646803,
          111.646803,
          109.646803,
          111.646803,
          110.646803,
          111.646803,
          111.646803,
          111.646803,
          112.646803,
          111.646803,
          113.646803,
          111.646803,
          114.646803,
          111.646803,
          115.646803,
          111.646803,
          116.646803,
          112.646803,
          109.646803,
          112.646803,
          110.646803,
          112.646803,
          111.646803,
          112.646803,
          112.646803,
          112.646803,
          113.646803,
          112.646803,
          114.646803,
          112.646803,
          115.646803,
          112.646803,
          116.646803,
          113.646803,
          109.646803,
          113.646803,
          110.646803,
          113.646803,
          111.646803,
          113.646803,
          112.646803,
          113.646803,
          113.646803,
          113.646803,
          114.646803,
          113.646803,
          115.646803,
          113.646803,
          116.646803,
          114.646803,
          109.646803,
          114.646803,
          110.646803,
          114.646803,
          111.646803,
          114.646803,
          112.646803,
          114.646803,
          113.646803,
          114.646803,
          114.646803,
          114.646803,
          115.646803,
          114.646803,
          116.646803,
          115.646803,
          109.646803,
          115.646803,
          110.646803,
          115.646803,
          111.646803,
          115.646803,
          112.646803,
          115.646803,
          113.646803,
          115.646803,
          114.646803,
          115.646803,
          115.646803,
          115.646803,
          116.646803,
          116.646803,
          109.646803,
          116.646803,
          110.646803,
          116.646803,
          111.646803,
          116.646803,
          112.646803,
          116.646803,
          113.646803,
          116.646803,
          114.646803,
          116.646803,
          115.646803,
          116.646803,
          116.646803
        ]
      ],
      "category_id": 0
    },
    {
      "bbox": [
        109.646803,
        193.878435,
        117.382585,
        201.417551
      ],
      "bbox_mode": 0,
      "segmentation": [
        [
          109.646803,
          193.878435,
          109.646803,
          194.878435,
          109.646803,
          195.878435,
          109.646803,
          196.878435,
          109.646803,
          197.878435,
          109.646803,
          198.878435,
          109.646803,
          199.878435,
          109.646803,
          200.878435,
          110.646803,
          193.878435,
          110.646803,
          194.878435,
          110.646803,
          195.878435,
          110.646803,
          196.878435,
          110.646803,
          197.878435,
          110.646803,
          198.878435,
          110.646803,
          199.878435,
          110.646803,
          200.878435,
          111.646803,
          193.878435,
          111.646803,
          194.878435,
          111.646803,
          195.878435,
          111.646803,
          196.878435,
          111.646803,
          197.878435,
          111.646803,
          198.878435,
          111.646803,
          199.878435,
          111.646803,
          200.878435,
          112.646803,
          193.878435,
          112.646803,
          194.878435,
          112.646803,
          195.878435,
          112.646803,
          196.878435,
          112.646803,
          197.878435,
          112.646803,
          198.878435,
          112.646803,
          199.878435,
          112.646803,
          200.878435,
          113.646803,
          193.878435,
          113.646803,
          194.878435,
          113.646803,
          195.878435,
          113.646803,
          196.878435,
          113.646803,
          197.878435,
          113.646803,
          198.878435,
          113.646803,
          199.878435,
          113.646803,
          200.878435,
          114.646803,
          193.878435,
          114.646803,
          194.878435,
          114.646803,
          195.878435,
          114.646803,
          196.878435,
          114.646803,
          197.878435,
          114.646803,
          198.878435,
          114.646803,
          199.878435,
          114.646803,
          200.878435,
          115.646803,
          193.878435,
          115.646803,
          194.878435,
          115.646803,
          195.878435,
          115.646803,
          196.878435,
          115.646803,
          197.878435,
          115.646803,
          198.878435,
          115.646803,
          199.878435,
          115.646803,
          200.878435,
          116.646803,
          193.878435,
          116.646803,
          194.878435,
          116.646803,
          195.878435,
          116.646803,
          196.878435,
          116.646803,
          197.878435,
          116.646803,
          198.878435,
          116.646803,
          199.878435,
          116.646803,
          200.878435
        ]
      ],
      "category_id": 0
    },
    {
      "bbox": [
        193.878435,
        109.646803,
        201.417551,
        117.382585
      ],
      "bbox_mode": 0,
      "segmentation": [
        [
          193.878435,
          109.646803,
          193.878435,
          110.646803,
          193.878435,
          111.646803,
          193.878435,
          112.646803,
          193.878435,
          113.646803,
          193.878435,
          114.646803,
          193.878435,
          115.646803,
          193.878435,
          116.646803,
          194.878435,
          109.646803,

and so on...

3. what you observed: The synthesized image before and after was the same, with no added bounding boxes. I'm going to attach the image. What confuses me is that there is no error anywhere, so I'm not sure where to begin in terms of debugging. I've checked the docs and scanned the colab example, but I can't find anything wrong. any help would be appreciated. 3

Environment:

And finally here's my environment:

------------------------  -----------------------------------------------------------------------------------
sys.platform              linux
Python                    3.6.10 |Anaconda, Inc.| (default, Jan  7 2020, 21:14:29) [GCC 7.3.0]
numpy                     1.18.1
detectron2                0.1.1 @/home/shared/miniconda3/envs/cu-py36/lib/python3.6/site-packages/detectron2
detectron2 compiler       GCC 7.5
detectron2 CUDA compiler  10.1
detectron2 arch flags     sm_61
DETECTRON2_ENV_MODULE     <not set>
PyTorch                   1.4.0 @/home/shared/miniconda3/envs/cu-py36/lib/python3.6/site-packages/torch
PyTorch debug build       False
CUDA available            True
GPU 0                     TITAN Xp
CUDA_HOME                 /usr/local/cuda
NVCC                      Cuda compilation tools, release 10.1, V10.1.243
Pillow                    7.0.0
torchvision               0.5.0 @/home/shared/miniconda3/envs/cu-py36/lib/python3.6/site-packages/torchvision
torchvision arch flags    sm_35, sm_50, sm_60, sm_70, sm_75
cv2                       4.2.0
------------------------  -----------------------------------------------------------------------------------
PyTorch built with:
  - GCC 7.3
  - Intel(R) Math Kernel Library Version 2019.0.5 Product Build 20190808 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;-gencode;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-hidden -fopenmp -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -O2 -fPIC -Wno-narrowing -Wall -Wextra -Wno-missing-field-initializers -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-stringop-overflow -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Wno-stringop-overflow, DISABLE_NUMA=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,

Again, my apologies for the lengthy post and data, but I have been stuck on this for a while now. Thanks in advance!

ppwwyyxx commented 4 years ago

Please provide complete runnable code so others can reproduce your issue.

chrisuzokwe commented 4 years ago

It was actually a simple solution. My image and my labels weren't scaled correctly causing the labeles to me smushed into the corner.