Turoad / lanedet

An open source lane detection toolbox based on PyTorch, including SCNN, RESA, UFLD, LaneATT, CondLane, etc.
Apache License 2.0
565 stars 93 forks source link

Inference code keyError #6

Closed emredo closed 3 years ago

emredo commented 3 years ago

(lanedet) emredo@emreninbilgisayari:~/lanedet$ python tools/detect.py configs/laneatt/resnet18_tusimple.py --img yol1.jpg --load_from /home/emredo/lanedet/work_dirs/TuSimple/20210623_163540_lr_3e-04_b_8/ckpt/best.pth --savedir ./savedimages

pretrained model: https://download.pytorch.org/models/resnet18-5c106cde.pth Traceback (most recent call last): File "tools/detect.py", line 84, in process(args) File "tools/detect.py", line 73, in process detect.run(p) File "tools/detect.py", line 47, in run data = self.preprocess(data) File "tools/detect.py", line 29, in preprocess data = self.processes(data) File "/home/emredo/lanedet/lanedet/datasets/process/process.py", line 35, in call data = t(data) File "/home/emredo/lanedet/lanedet/datasets/process/generate_lane_line.py", line 127, in call line_strings_org = self.lane_to_linestrings(sample['lanes']) KeyError: 'lanes'

Hi, when I try to use detect.py it gives an error which was given above. Why am I getting this error? Thank you for repo and everything.

Turoad commented 3 years ago

Currently, you can try replace 'data = {'img': img}' by 'data = {'img': img, 'lanes': []}'.

     def preprocess(self, img_path):
         ori_img = cv2.imread(img_path)
         img = ori_img[self.cfg.cut_height:, :, :].astype(np.float32)
-        data = {'img': img}
+        data = {'img': img, 'lanes': []}
         data = self.processes(data)
         data['img'] = data['img'].unsqueeze(0)
         data.update({'img_path':img_path, 'ori_img':ori_img})

I will fix it at soon.

emredo commented 3 years ago

oh it worked, thanks a lot and also I appreciate for emergency answer.