yrcong / RelTR

RelTR: Relation Transformer for Scene Graph Generation: https://arxiv.org/abs/2201.11460v2
248 stars 49 forks source link

AttributeError: 'Namespace' object has no attribute 'dataset' #1

Closed xixihawokao closed 2 years ago

xixihawokao commented 2 years ago

hi, i just follow readme/usage and type this conmand: python inference.py --img_path demo/vg2.jpg --resume ckpt/checkpoint0149.pth and i get this:

(scene_graph_benchmark) bash-4.2$ python inference.py --img_path demo/vg2.jpg --resume ckpt/checkpoint0149.pth Namespace(aux_loss=True, backbone='resnet50', dec_layers=6, device='cuda', dilation=False, dim_feedforward=2048, dropout=0.1, enc_layers=6, hidden_dim=256, img_path='demo/vg2.jpg', lr_backbone=1e-05, nheads=8, num_entities=100, num_triplets=200, position_embedding='sine', pre_norm=False, resume='ckpt/checkpoint0149.pth', return_interm_layers=False) yes Traceback (most recent call last): File "inference.py", line 191, in main(args) File "inference.py", line 104, in main model = build_model(args) File "/home/user/JL/myhome/juyterNotebook_folder/test/test_for_code/sgg_for_sgbEnv/reltr/RelTR-main/models/init.py", line 5, in build_model return build(args) File "/home/user/JL/myhome/juyterNotebook_folder/test/test_for_code/sgg_for_sgbEnv/reltr/RelTR-main/models/reltr.py", line 377, in build num_classes = 151 if args.dataset != 'oi' else None #TODO: openimage v6 AttributeError: 'Namespace' object has no attribute 'dataset'

CurtisDeCastro commented 2 years ago

Same issue here

yrcong commented 2 years ago

Hi all,

sorry for the late reply. I got the point. The error is caused by the version change. Now I have fixed the inference code. Actually, nothing changed only adding some attributes for the initialization.

Now I can run inference.py successfully:) You could have a try now.

thanks for the update!

xixihawokao commented 2 years ago

thanks!it’s nice job,but when i use this find another problem my datasets is coco OpenEnded_mscoco_val2014_questions, specially,for “COCO_val2014_000000339761.jpg”this picture,i get this: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Input In [9], in <cell line: 70>() 103 topk = 10 104 keep_queries = torch.nonzero(keep, as_tuple=True)[0] --> 105 indices = torch.argsort(-probas[keep_queries].max(-1)[0] probas_sub[keep_queries].max(-1)[0] probas_obj[keep_queries].max(-1)[0])[:topk] 106 keep_queries = keep_queries[indices] 108 # use lists to store the outputs via up-values

RuntimeError: cannot perform reduction function max on tensor with no elements because the operation does not have an identity ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ There are other pictures that will do the same,could you please solve this [problem?this dataset is from (https://okvqa.allenai.org/download.html).

yrcong commented 2 years ago

The error shows no relationships above the threshold are found by RelTR.

When you are using a customized image or image from other datasets. It could be that the entities in the image are not included in the VG-150 classes (also relationships).

In this case, you could lower the threshold in Line137/138 (I set it to 0.3, for your example, I use 0.1 and get something interesting). However, the lower threshold means that RelTR is not confident in the output so there could be some dummy triplets.

I will also release the pre-trained model on OpenImages which contains more than 250 object categories in the future.