Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not able to show predictions for COCO like dataset for pascal.ipynb notebook #585

Open
Monk5088 opened this issue Jul 5, 2022 · 0 comments

Comments

@Monk5088
Copy link

Monk5088 commented Jul 5, 2022

I tried using the notebook :https://github.com/fastai/course-v3/blob/7fceebfd14d4f3bc7e0ec649834309b8cb786e40/nbs/dl2/pascal.ipynb
I loaded the dataset according to coco and then used the functions after

learn = learn.load('stage2-256')
img,target = next(iter(data.valid_dl))
with torch.no_grad():
    output = learn.model(img)
First we need to remove the padding that was added to collate our targets together.

def unpad(tgt_bbox, tgt_clas, pad_idx=0):
    i = torch.min(torch.nonzero(tgt_clas-pad_idx))
    return tlbr2cthw(tgt_bbox[i:]), tgt_clas[i:]-1+pad_idx
Then we process the outputs of the model: we convert the activations of the regressor to bounding boxes and the predictions to probabilities, only keeping those above a given threshold.

def process_output(output, i, detect_thresh=0.25):
    "Process `output[i]` and return the predicted bboxes above `detect_thresh`."
    clas_pred,bbox_pred,sizes = output[0][i], output[1][i], output[2]
    anchors = create_anchors(sizes, ratios, scales).to(clas_pred.device)
    bbox_pred = activ_to_bbox(bbox_pred, anchors)
    clas_pred = torch.sigmoid(clas_pred)
    detect_mask = clas_pred.max(1)[0] > detect_thresh
    bbox_pred, clas_pred = bbox_pred[detect_mask], clas_pred[detect_mask]
    bbox_pred = tlbr2cthw(torch.clamp(cthw2tlbr(bbox_pred), min=-1, max=1))    
    scores, preds = clas_pred.max(1)
    return bbox_pred, scores, press
...........

And the rest of the methods after this ,but I am not able to generate EVAL metrics for the same, could you please share a notebook which Is same as pascal.ipynb but for coco like dataset object detection problem.
The tensors seem to be empty due to some conversion error as pascal and coco has different format for annotations and for bboxes .
Requesting developers to please share a similar notebook for coco object detection too, also if anyone already has any resources code snippets, notebooks, etc for the above problem , please do share with in comments
Thanking you all in advance,
Harshit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant