lucastabelini / PolyLaneNet

Code for the paper entitled "PolyLaneNet: Lane Estimation via Deep Polynomial Regression" (ICPR 2020)
https://arxiv.org/abs/2004.10924
MIT License
295 stars 74 forks source link

Division by 0 error #4

Closed rubeea closed 4 years ago

rubeea commented 4 years ago

Hi, I am trying to test the trained model on my custom image dataset. I modified the config.yaml file as per the suggestions in another issue but I get the following error

Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm\helpers\pydev\pydevd.py", line 2060, in main() File "C:\Program Files\JetBrains\PyCharm\helpers\pydev\pydevd.py", line 2054, in main globals = debugger.run(setup['file'], None, None, is_module) File "C:\Program Files\JetBrains\PyCharm\helpers\pydev\pydevd.py", line 1405, in run return self._exec(is_module, entry_point_fn, module_name, file, globals, locals) File "C:\Program Files\JetBrains\PyCharm\helpers\pydev\pydevd.py", line 1412, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "C:\Program Files\JetBrains\PyCharm\helpers\pydev_pydev_imps_pydevexecfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "C:/Users/Xyedj/PycharmProjects/PolyLaneNet-master/test.py", line 162, in , mean_loss = test(model, test_loader, evaluator, exp_root, cfg, epoch=test_epoch, view=args.view) File "C:/Users/Xyedj/PycharmProjects/PolyLaneNet-master/test.py", line 78, in test return evaluator, loss / total_iters ZeroDivisionError: division by zero

I believe it has something to do with the dataset I am using. Can you specify the dataset format to be used with test.py. Do I only need the test images in .jpg or I should have their associated annotations as well?

lucastabelini commented 4 years ago

It seems the dataset loader could not find any data. Are you using the NoLabelDataset as suggested in #2 ? This class loads every image in a directory recursively searching for images with the extension provided (e.g., .jpg), but does not load any annotations.

It would be easier for me to help if you could provide the config.yaml used.

rubeea commented 4 years ago

Yes I used that setting. Here is my config file:

Training settings

seed: 1 exps_dir: 'experiments' iter_log_interval: 1 iter_time_window: 100 model_save_interval: 1 backup: model: name: PolyRegression parameters: num_outputs: 35 # (5 lanes) * (1 conf + 2 (upper & lower) + 4 poly coeffs) pretrained: true backbone: 'efficientnet-b0' pred_category: false curriculum_steps: [9000, 9000, 0, 0] loss_parameters: conf_weight: 1 lower_weight: 1 upper_weight: 1 cls_weight: 0 poly_weight: 300 batch_size: 16 epochs: 2695 optimizer: name: Adam parameters: lr: 3.0e-4 lr_scheduler: name: CosineAnnealingLR parameters: T_max: 385

Testing settings

test_parameters: conf_threshold: 0.5

Dataset settings

datasets: train: type: LaneDataset parameters: dataset: nolabel_dataset split: train img_size: [360, 640] normalize: true aug_chance: 0.9090909090909091 # 10/11 augmentations:

rubeea commented 4 years ago

I got it working thanks. There was a problem with my dataset path :) I have one question though, how well does your model generalize for line detection in general and not specifically road lane-line detection?

lucastabelini commented 4 years ago

The method was evaluated only on the task of lane detection, so I don't know how it performs in other tasks. Nevertheless, it should perform well depending on the kind of images used.

nitvishnoi commented 10 months ago

Hi , i am facing similar issue with below error.

[2023-11-25 18:47:26,144] [INFO] Starting testing. [2023-11-25 18:47:26,636] [INFO] Testing time: 0.3135 [2023-11-25 18:47:26,637] [INFO] [2023-11-25 18:47:26,637] [ERROR] Uncaught exception Traceback (most recent call last): File "/PolyLaneNet/test.py", line 160, in _, mean_loss = test(model, test_loader, evaluator, exp_root, cfg, epoch=test_epoch, view=args.view) File "/PolyLaneNet/test.py", line 77, in test return evaluator, loss / total_iters ZeroDivisionError: division by zero

below is my config file used and i verified the image path for test, images are there. Not getting sure what may be the issue?

Training settings

seed: 0 exps_dir: 'experiments' iter_log_interval: 1 iter_time_window: 100 model_save_interval: 1 backup: model: name: PolyRegression parameters: num_outputs: 35 # (5 lanes) * (1 conf + 2 (upper & lower) + 4 poly coeffs) pretrained: true backbone: 'resnet50' pred_category: false curriculum_steps: [0, 0, 0, 0] loss_parameters: conf_weight: 1 lower_weight: 1 upper_weight: 1 cls_weight: 0 poly_weight: 300 batch_size: 16 epochs: 1 optimizer: name: Adam parameters: lr: 3.0e-4 lr_scheduler: name: CosineAnnealingLR parameters: T_max: 385

Testing settings

test_parameters: conf_threshold: 0.5

Dataset settings

datasets: train: type: LaneDataset parameters: dataset: tusimple split: train img_size: [360, 640] normalize: true aug_chance: 0.9090909090909091 # 10/11 augmentations:

nitvishnoi commented 10 months ago

Seems like some spacing was the issue, that error is gone, but facing some new error below one.

[2023-11-25 19:27:44,782] [INFO] Starting testing. [2023-11-25 19:27:47,249] [INFO] Testing iteration: 1/20 [2023-11-25 19:28:18,194] [ERROR] Uncaught exception Traceback (most recent call last): File "PolyLaneNet/test.py", line 160, in _, mean_loss = test(model, test_loader, evaluator, exp_root, cfg, epoch=test_epoch, view=args.view) File "PolyLaneNet/test.py", line 61, in test preds = test_loader.dataset.draw_annotation( File "PolyLaneNet/lib/datasets/lane_dataset.py", line 172, in draw_annotation cv2.putText(img, str(i), tuple(points[0]), fontFace=cv2.FONT_HERSHEY_COMPLEX, fontScale=1, color=color) cv2.error: OpenCV(4.8.1) :-1: error: (-5:Bad argument) in function 'putText'

Overload resolution failed:

  • Layout of the output array img is incompatible with cv::Mat
  • Expected Ptr for argument 'img'

Any thoughts?