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

script to test my own images #2

Closed kaishijeng closed 4 years ago

kaishijeng commented 4 years ago

Do you have python script which can be used to test my own images? I tried to modify test.py, but without any success.

Thanks,

lucastabelini commented 4 years ago

If you only want qualitative results (i.e., you don't want to compute metrics), you can use the NoLabelDataset class. To use it on one of the pretrained models, you can copy its config file (.yaml) and change the dataset settings. In the dataset settings section of this file, you can set the test dataset like this (leaving the rest as it is):

  test: &test
    type: LaneDataset
    parameters:
      dataset: nolabel_dataset
      normalize: true # Wheter to normalize the input data. Use the same value used in the pretrained model (all pretrained models that I provided used normalization, so you should leave it as it is)
      augmentations: [] # List of augmentations. You probably want to leave this empty for testing
      img_h: 360 # The height of your test images (they shoud all have the same size)
      img_w: 640 # The width of your test images
      img_size: [360, 640] # Yeah, this parameter is duplicated for some reason, will fix this when I get time (feel free to open a pull request :))
      max_lanes: 5 # Same number used in the pretrained model. If you use a model pretrained on TuSimple (most likely case), you'll use 5 here
      root: "path/to/files" # Path to the directory containing your test images. The loader will look recursively for image files in this directory
      img_ext: ".jpg" # Test images extension (e.g., .png, .jpg)"

During the test, when running the test.py script, you can use the flag --view to visualize predictions.

If you want quantitative results too (i.e., metrics), you will have to implement a loader for your dataset. If that's the case, feel free to ask for help on that.

kaishijeng commented 4 years ago

I tried your suggestion with NoLabelDataset, but got an error below:

AttributeError: module 'lib.datasets' has no attribute 'NoLabelDataset'

Thanks,

kaishijeng commented 4 years ago

More info about errors:

Traceback (most recent call last): File "./test.py", line 141, in test_dataset = cfg.get_dataset("test") File "/home/user/2TB/LaneDetection/PolyLaneNet/lib/config.py", line 23, in get_dataset self.config['datasets'][split]['type'])(**self.config['datasets'][split]['parameters']) AttributeError: module 'lib.datasets' has no attribute 'NoLabelDataset'

lucastabelini commented 4 years ago

Sorry about that. There was a line missing in nolabel_dataset.py. I added it and updated the repo, please pull it again. Also, the config I had shown was not right, so I edited my previous reply and fixed it. Please try again with the fixed code and config.

kaishijeng commented 4 years ago

It works now. But quality is not so good for one test image I have tried:

image

source image is

image

lucastabelini commented 4 years ago

This is expected. Many models based on deep learning will have a hard time dealing with images from different datasets, since the general structure of the image can vary a lot. To fix this, you'll have to finetune the pretrained model on your dataset, a process which was done in the paper, when we finetuned a model trained on TuSimple on LLAMAS and ELAS.

kaishijeng commented 4 years ago

Thanks.