fundamentalvision / Deformable-DETR

Deformable DETR: Deformable Transformers for End-to-End Object Detection.
Apache License 2.0
3.24k stars 523 forks source link

Train Segmentation occur ERROR: forward() takes 1 positional argument but 2 were given #84

Open QianLingjun opened 3 years ago

QianLingjun commented 3 years ago

first: train box was ok . the command for training Deformable DETR on 4 GPUs is as following: GPUS_PER_NODE=4 ./tools/run_dist_launch.sh 4 ./configs/r50_deformable_detr_plus_iterative_bbox_refinement_plus_plus_two_stage.sh

second: train segmentation occur ERROR. I change files of ./configs/r50_deformable_detr_plus_iterative_bbox_refinement_plus_plus_two_stage.sh


!/usr/bin/env bash

set -x

EXP_DIR=./outputs/segm_model PY_ARGS=${@:1}

python -u main.py \ --output_dir ${EXP_DIR} \ --with_box_refine \ --two_stage \ --masks ${PY_ARGS}


the ERROR information is this:

File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, *kwargs)
File "/home/qlj/projects/Deformable-DETR-main/models/segmentation.py", line 51, in forward
src_proj = self.detr.input_proj(src)
File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(
input, **kwargs)
TypeError: forward() takes 1 positional argument but 2 were given

what can i do to address this problem? or any other method to train segmentation.(note, FACEBOOK DETR is OK in box and segmentation train or inference). Looking forward to your reply. Thinks.

iwan933 commented 3 years ago

@QianLingjun the segmentation head is not implemented for the deformable DETR. The specific error is raised as input_proj is a ModuleList. You have to rewrite the segmentation head to your needs.