yosungho / LineTR

Line as a Visual Sentence: Context-aware Line Descriptor for Visual Localization (Line Transformer)
Other
238 stars 35 forks source link

ZeroDivisionError #11

Closed BlueAkoasm closed 2 years ago

BlueAkoasm commented 2 years ago

Hello, when i run the original code, it always occurs the ZeroDivisionError, it also happens after i change the dataset. The reason is that the TP and FP are both 0 at the same time, so the precision is very low. It seems like the network is not converging. What should i do? Traceback (most recent call last): File "train.py", line 263, in <module> main() File "train.py", line 93, in main is_best = run_epochs("val", conf, val_loader, model, None, logger, epoch, device, lr_scheduler) File "train.py", line 233, in run_epochs result.evaluate(pred, batch_data, loss.item(), batch_index) File "/home/linux/catkin_ws/LineTR-train/evaluations/metric.py", line 40, in evaluate precision, recall, f1_score = self.eval_pr.get_precision_recall(score_pred, score_gt) File "/home/linux/catkin_ws/LineTR-train/evaluations/evaluate_pr.py", line 31, in get_precision_recall precision = np.average(np.nan_to_num(TP / (TP+FP)))*100. ZeroDivisionError: division by zero

yosungho commented 2 years ago

The error occurred when TP and FP are zeros, so I added a small number to prevent the zero denominators. Thanks for reporting the bug.