PRBonn / lidar-bonnetal

Semantic and Instance Segmentation of LiDAR point clouds for autonomous driving
http://semantic-kitti.org
MIT License
959 stars 206 forks source link

Failure with infer #67

Closed jonathanslee4 closed 4 years ago

jonathanslee4 commented 4 years ago

I'm having trouble running infer.py. Here is what I'm running: ./infer.py -d /Users/jonathan/desktop/asl/lidar-bonnetal/train/tasks/semantic/ -l /Users/jonathan/desktop/asl/lidar-bonnetal/train/tasks/semantic/labels -m /Users/jonathan/desktop/asl/lidar-bonnetal/train/tasks/semantic/squeezeseg

And here is the error: File "../..//tasks/semantic/dataset/kitti/parser.py", line 101, in init assert(len(scan_files) == len(label_files)) AssertionError

I'm using a .bin file of a single lidar scan for the dataset, which is located in the semantic/sequences/00/velodyne folder. Any pointers? Thank you for your time!

jbehley commented 4 years ago

Please see Andres's comment https://github.com/PRBonn/lidar-bonnetal/issues/62#issuecomment-683716148:

As for the labels for inference, they are there for another script that used them for evaluation directly after inference, but this will not work on the test set. It is a bug that I have fixed internally but have not released yet. It is solved by making gt=True, into gt=False in this line.

Hope that fixes your issue.

jonathanslee4 commented 4 years ago

I'm getting a new error from changing that line:

File "../..//tasks/semantic/dataset/kitti/parser.py", line 290, in init assert len(self.validloader) > 0 AssertionError

Any advice? Thank you for the help.

jbehley commented 4 years ago

The code expects the "normal" semantic kitti folders, thus it loads also the validation data and check if the data is there. an easy fix would be if you modify the semantic-kitti.yaml such that train valid and test contain your sequence folder.

Here:
https://github.com/PRBonn/lidar-bonnetal/blob/423311109bb6a075c8d44f545b624b42a61f8d42/train/tasks/semantic/config/labels/semantic-kitti.yaml#L187-L212

Thus if you created an folder 00 containing your scans, just put there under train, valid and test 0. That should fix the problem.

jonathanslee4 commented 4 years ago

Did you mean to add "-00" to the train, valid, and test sections? I tried that and unfortunately received the same error. The path to my scan file is /Users/jonathan/desktop/asl/lidar-bonnetal/train/tasks/semantic/sequences/00/velodyne.

jbehley commented 4 years ago

Sorry, I currently have here the repo not running, thus have to deduce from looking at the code.

split: # sequence numbers 
   train: 
     - 0 
   valid: 
     - 0
   test: 
     - 0

And you should edit the data_cfg.yaml in your squeezeseg model folder. Sorry for the confusion.

jonathanslee4 commented 4 years ago

Here's what I'm getting now.

FileExistsError: [Errno 17] File exists: '/Users/jonathan/desktop/asl/lidar-bonnetal/train/tasks/semantic/labels/sequences/00'

All I'm doing is trying to get labels on a single lidar scan, which is a file called 000000.bin in /Users/jonathan/desktop/asl/lidar-bonnetal/train/tasks/semantic/sequences/00/velodyne. I'm using the squeezeseg model, which I've put in the semantic directory. I also created an empty folder called labels in the semantic directory, which I write the path to when I run infer.

jbehley commented 4 years ago

the log folder already exists. (It should be deleted, but appearently this did not happen. You are using windows? Might be that it does not support rmtree?) Try to use a log folder that does not exist (e.g., -l /Users/jonathan/desktop/asl/lidar-bonnetal/train/tasks/semantic/log).

jonathanslee4 commented 4 years ago

I tried that, with a similar error: FileExistsError: [Errno 17] File exists: '/Users/jonathan/desktop/asl/lidar-bonnetal/train/tasks/semantic/log/sequences/00'

It looks like wherever I specify the path for the label folder, a new folder called sequences gets created which has a subfolder called 00. In the subfolder is another folder called predictions: /Users/jonathan/desktop/asl/lidar-bonnetal/train/tasks/semantic/log/sequences/00/predictions

jbehley commented 4 years ago

ah okay. I see what is the problem: now train, valid and test are 0. as infer is always doing inference for train, valid, and test, one needs also dedicated subsets. as a workaround you can copy your 00 folder to 01, and 02 and then set in the data_cfg.yaml:

split: # sequence numbers 
   train: 
     - 0 
   valid: 
     - 1
   test: 
     - 2

As said before, the code works with the "normal" semantic kitti structure which has distinct train, validation and test sequences.

jonathanslee4 commented 4 years ago

I got another error, but I'm definitely making progress!

File "../..//tasks/semantic/dataset/kitti/parser.py", line 290, in init assert len(self.validloader) > 0

I changed data_cfg.yaml as advised. Here is my current folder structure:

Screen Shot 2020-10-18 at 6 53 46 PM

I'm running this command: ./infer.py -d /Users/jonathan/desktop/asl/lidar-bonnetal/train/tasks/semantic/ -l /Users/jonathan/desktop/asl/lidar-bonnetal/train/tasks/semantic/log -m /Users/jonathan/desktop/asl/lidar-bonnetal/train/tasks/semantic/squeezeseg

jbehley commented 4 years ago

you should have at least 1 scan in the fake validation set folder or testset folder.

jonathanslee4 commented 4 years ago

I don't think I have those folders. Should I create them, and if so, in which directory?

jonathanslee4 commented 4 years ago

Actually, I just understood and fixed the error, and got the label files to show up. The thing now is that when I run visualize, I receive the following error: Traceback (most recent call last): File "./visualize.py", line 129, in assert(len(label_names) == len(scan_names))

The command I'm running is: ./visualize.py -d /Users/jonathan/desktop/asl/lidar-bonnetal/train/tasks/semantic/ -p /Users/jonathan/desktop/asl/lidar-bonnetal/train/tasks/semantic/log

Thank you so much for the help.

Screen Shot 2020-10-19 at 12 43 30 PM
jbehley commented 4 years ago

Here are some pointers to fix the problem:

  1. Enusre that the folder are correct.
  2. I do not know if it is relevant, but you might have to specify a sequence (-s 0) for visualization.
  3. For debugging you can just print the label_names and scan_names to figure out what is missing.
he-guo commented 4 years ago

Thank you for your discussion. I also solved the similar problem, but I also want to ask how to convert the point_cloud2 lidar data into bin file.

jbehley commented 4 years ago

Run a ROS node consuming the lidar point clouds and each meassage into a file containing x,y,z,r as binary floats. your file should contain only the cordinates x,y,z and the remission r of each point. (if now remission, simply use 0.5 or some other constant.)

Since your original problem seems to be solved, I will now close this issue. Feel free to open a new issue or reopen this issue again if you still experience problems with infer.

he-guo commented 4 years ago

Sorry to bother you again, I generated the bin file like this:

int32_t num = 64*2048;//1000000
float *data = (float*)malloc(num*sizeof(float));

pcl::PointCloud<pcl::PointXYZI>::Ptr cloud1(new pcl::PointCloud<pcl::PointXYZI>);
pcl::fromROSMsg (*msg, *cloud1);
for(int i=0;i < cloud1->points.size();i++){
    *(data+4*i+0)=cloud1->points[i].x;
    *(data+4*i+1)=cloud1->points[i].y;
    *(data+4*i+2)=cloud1->points[i].z;
    *(data+4*i+3)=cloud1->points[i].intensity;
}

But the program will report an error like this:

IndexError: index -2147483648 is out of bounds for axis 0 with size 64

What can I do to make sure the index is in range? thanks

jbehley commented 4 years ago

it is really hard to understand where the problem is happening. Please provide also the stack trace.

And in your c++ code, I would replace the pointer-based data array with an std::vector<float>, which you can even resize to 4*cloud1->size() appropriately or simply use push_back()

rohithsaro commented 2 years ago

@he-guo Did you solve the index error ? :) Eager to hear from you soon.