Closed bemoregt closed 2 years ago
Did you remember to change this line: self.coco_eval[iou_type] = COCOeval(coco_gt, iouType=iou_type) in coco_eval.py to
coco_eval = COCOeval(coco_gt, iouType=iou_type)
coco_eval.params.kpt_oks_sigmas = np.array([.5, .5]) / 10.
self.coco_eval[iou_type] = coco_eval
In your case coco_eval.params.kpt_oks_sigmas = np.array([.5, .5]) / 10.
probably should be different since you have 6 keypoints and not just 2.
Hi, @alexppppp .
I met this error when train with this code.
I used my own dataset which have 6 keypoints & 1 box in image.
Epoch: [0] [ 0/56] eta: 0:41:06 lr: 0.000019 loss: 9.5321 (9.5321) loss_classifier: 0.7595 (0.7595) loss_box_reg: 0.0000 (0.0000) loss_keypoint: 8.0790 (8.0790) loss_objectness: 0.6910 (0.6910) loss_rpn_box_reg: 0.0026 (0.0026) time: 44.0517 data: 0.0325 Epoch: [0] [55/56] eta: 0:00:44 lr: 0.001000 loss: 7.7045 (8.4640) loss_classifier: 0.0419 (0.2365) loss_box_reg: 0.0010 (0.0107) loss_keypoint: 7.2650 (7.6186) loss_objectness: 0.4400 (0.5934) loss_rpn_box_reg: 0.0027 (0.0048) time: 42.6397 data: 0.0408 Epoch: [0] Total time: 0:41:48 (44.7877 s / it) creating index... index created!
[W ParallelNative.cpp:214] Warning: Cannot set number of intraop threads after parallel work has started or after set_num_threads call when using native parallel backend (function set_num_threads)
ValueError Traceback (most recent call last) Input In [17], in
21 train_one_epoch(model, optimizer, data_loader_train, device, epoch, print_freq=1000)
22 lr_scheduler.step()
---> 23 evaluate(model, data_loader_test, device)
25 # Save model weights after training
26 torch.save(model.state_dict(), './weights/nz_krcnn_res50.pth')
File /usr/local/lib/python3.8/site-packages/torch/autograd/grad_mode.py:28, in _DecoratorContextManager.call..decorate_context(*args, kwargs)
25 @functools.wraps(func)
26 def decorate_context(*args, *kwargs):
27 with self.class():
---> 28 return func(args, kwargs)
File ~/Music/dataZ/meca_nz_krcnn/engine.py:102, in evaluate(model, data_loader, device) 100 res = {target["image_id"].item(): output for target, output in zip(targets, outputs)} 101 evaluator_time = time.time() --> 102 coco_evaluator.update(res) 103 evaluator_time = time.time() - evaluator_time 104 metric_logger.update(model_time=model_time, evaluator_time=evaluator_time)
File ~/Music/dataZ/meca_nz_krcnn/coco_eval.py:43, in CocoEvaluator.update(self, predictions) 41 coco_eval.cocoDt = coco_dt 42 coco_eval.params.imgIds = list(img_ids) ---> 43 img_ids, eval_imgs = evaluate(coco_eval) 45 self.eval_imgs[iou_type].append(eval_imgs)
File ~/Music/dataZ/meca_nz_krcnn/coco_eval.py:194, in evaluate(imgs) 192 def evaluate(imgs): 193 with redirect_stdout(io.StringIO()): --> 194 imgs.evaluate() 195 return imgs.params.imgIds, np.asarray(imgs.evalImgs).reshape(-1, len(imgs.params.areaRng), len(imgs.params.imgIds))
File /usr/local/lib/python3.8/site-packages/pycocotools/cocoeval.py:148, in COCOeval.evaluate(self) 146 elif p.iouType == 'keypoints': 147 computeIoU = self.computeOks --> 148 self.ious = {(imgId, catId): computeIoU(imgId, catId) \ 149 for imgId in p.imgIds 150 for catId in catIds} 152 evaluateImg = self.evaluateImg 153 maxDet = p.maxDets[-1]
File /usr/local/lib/python3.8/site-packages/pycocotools/cocoeval.py:148, in(.0)
146 elif p.iouType == 'keypoints':
147 computeIoU = self.computeOks
--> 148 self.ious = {(imgId, catId): computeIoU(imgId, catId) \
149 for imgId in p.imgIds
150 for catId in catIds}
152 evaluateImg = self.evaluateImg
153 maxDet = p.maxDets[-1]
File /usr/local/lib/python3.8/site-packages/pycocotools/cocoeval.py:229, in COCOeval.computeOks(self, imgId, catId) 227 dx = np.max((z, x0-xd),axis=0)+np.max((z, xd-x1),axis=0) 228 dy = np.max((z, y0-yd),axis=0)+np.max((z, yd-y1),axis=0) --> 229 e = (dx2 + dy2) / vars / (gt['area']+np.spacing(1)) / 2 230 if k1 > 0: 231 e=e[vg > 0]
ValueError: operands could not be broadcast together with shapes (6,) (2,)
What's wrong to me ?
Thanks in advance. Best, @bemoregt.