-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
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