Skip to content

some bugs about test.py #7

Open
@JJJYmmm

Description

Hi Shariatnia, I meet some trouble in test.py

issue 1

Firstly, function postprocess does not consider the situation where the model detect nothing,so it will pass empty sequence(<BOS><EOS>) to tokenizer.decoder, and get error like #5. Considering this case, we can add a judgment conditionEOS_idx == 1 to include the empty seq case.

for i, EOS_idx in enumerate(EOS_idxs.tolist()):
        if EOS_idx == 0 or EOS_idx ==1: # invalid idx which EOS_idx = 0 or the model detect nothing when EOS_idx = 1 
            all_bboxes.append(None)
            all_labels.append(None)
            all_confs.append(None)
            continue

issue 2

Secondly,If I put CFG.run_eval=True and run test.py,I got nothing in voc_preds.csv.I try debug and I found that the problem comes from misjudgment of the type.I think the code wants to filter entries without prediction boxes.But at that time, x's type is numpy.ndarray

# preds_df = preds_df[preds_df['bbox'].map(lambda x: isinstance(x, list))].reset_index(drop=True)
# fix : list -> np.ndarray
preds_df = preds_df[preds_df['bbox'].map(lambda x: isinstance(x, np.ndarray))].reset_index(drop=True)

issue 3

The last issue occurs below.I think the code wants to assign the predict result with image id. It is OK when valid_df doesn't have duplicate entries.

preds_df = pd.DataFrame()
valid_df = valid_df.iloc[:len(all_bboxes)]
preds_df['id'] = valid_df['id'].copy()
preds_df['bbox'] = all_bboxes
preds_df['label'] = all_labels
preds_df['conf'] = all_confs

Actually,valid_df have some duplicate entries, because different objects in one image are save dependently.So it will lose some image and break the mapping relationship between images and predictions when useing slice [:len(all_bboxes)] to get corresponding img_id.
To fix it, I use valid_df['id'].unique() to get validation set's id, it works because the order is fixed(dataloader,shuffle=True)

preds_df = pd.DataFrame()
preds_df['id'] = valid_df['id'].unique().copy()
preds_df['bbox'] = all_bboxes
preds_df['label'] = all_labels
preds_df['conf'] = all_confs

Then I use the modified code and the weight file you provided for testing,and get mAP=0.329(better than 0.264).
image-20230901001735855

Finally, thank you again for your tutorial. It's really useful!

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions