qianyuzqy / TransVOD_Lite

(TPAMI 2023) TransVOD:End-to-End Video Object Detection with Spatial-Temporal Transformers (implementations of TransVOD Lite).
Apache License 2.0
37 stars 6 forks source link

Problem with single class object detection #11

Closed Sairam13001 closed 1 year ago

Sairam13001 commented 1 year ago

Hi @qianyuzqy,

I am running your code on a custom dataset that has only one class (say "class A"). The code is working when I set the number of classes as 2 (So, the model gives classification scores for two classes now - "Class A" and "Not class A". The outputs['pred_logits'] shape is (bs, 100, 2) ).

I am trying to run the model by setting "num_classes = 1". When we pass the images through the model, I am getting the output as follows now - Outputs['pred_logits'] has shape (bs, 100, 1) and Outputs['pred_boxes'] has shape (bs, 100, 4).

I am getting the follwoing error though:

/opt/conda/conda-bld/pytorch_1616554793803/work/aten/src/ATen/native/cuda/IndexKernel.cu:142: operator(): block: [0,0,0], thread: [0,0,0] Assertion index >= -sizes[i] && index < sizes[i] && "index out of bounds" failed. . . . . . . /opt/conda/conda-bld/pytorch_1616554793803/work/aten/src/ATen/native/cuda/IndexKernel.cu:142: operator(): block: [0,0,0], thread: [127,0,0] Assertion index >= -sizes[i] && index < sizes[i] && "index out of bounds" failed.

Traceback (most recent call last): File "main.py", line 348, in main(args) File "main.py", line 305, in main train_stats = train_one_epoch( File "/workspace/engine_single.py", line 85, in train_one_epoch loss_dict = criterion(outputs, targets) File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(*input, *kwargs) File "/workspace/models/deformable_detr_single.py", line 675, in forward indices = self.matcher(outputs_without_aux, targets) File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(input, **kwargs) File "/workspace/models/matcher.py", line 105, in forward cost_giou = -generalized_box_iou(out_box_xyxy, File "/workspace/util/box_ops.py", line 61, in generalized_box_iou assert (boxes1[:, 2:] >= boxes1[:, :2]).all() RuntimeError: CUDA error: device-side assert triggered terminate called after throwing an instance of 'std::runtime_error' what(): NCCL error in: /opt/conda/conda-bld/pytorch_1616554793803/work/torch/lib/c10d/../c10d/NCCLUtils.hpp:155, unhandled cuda error, NCCL version 2.7.8 ncclUnhandledCudaError: Call to CUDA function failed.

Could you kindly let me know how I can solve this problem?

qianyuzqy commented 1 year ago

Hi, @Sairam13001 ,

Sorry for the late reply. Your former understanding is right, when training on a custom dataset that has N classes, you should set the number of classes as N+1 since there are N foreground classes and 1 background class (None of these N classes), and it works. If your custom dataset has only one class, you should set the number of classes as 2. It is all right.

fisal-ITS commented 1 year ago

Hi, I wonder if you can successfully run TransVOD Lite for single object detection. Did you manage to do the evaluation?

Sairam13001 commented 1 year ago

Hi @fisal-ITS, by single object detection, do you mean a single class in the dataset or single object per image?

Anyways, I was able to run TransVoD Lite for single class object detection and many images of the dataset I am using have single object in them.

fisal-ITS commented 1 year ago

Hai @Sairam13001 thanks for your reply. What I mean is single class object detection. I am very grateful for any help in advance. I also managed to run single class object detection. But I think the results I get are still very low.

May I know about the config that you are using? And how much data you used for training?