YOLOP
YOLOP copied to clipboard
Does the size of the input image have to be [720,1280] ? When testing images of other sizes, an indexError is always reported.
What need to do if want to test images of different sizes? Thanks very much.
similar error, I believe the network has SPP so the input size should not be a factor, should be the visualisation code fixing the size. I see similar errors:
python tools/demo.py ...
line 57, in show_seg_result
img[color_mask != 0] = img[color_mask != 0] * 0.5 + color_seg[color_mask != 0] * 0.5
IndexError: boolean index did not match indexed array along dimension 0; dimension is 1208 but corresponding boolean dimension is 1116
me too, how to solve it ?
@shgrace233 @timothylimyl @Miaonika did any of you solve it? I have the same problem
@shgrace233 @Miaonika @timothylimyl @callmesora
u have to set default image size
(python3 demo.py --img-size = int())
or put resizing in DemoDataset.py
if self.video_flag[self.count]:
# Read video
self.mode = 'video'
ret_val, img0 = self.cap.read()
img0 = cv2.resize(img0, (640,640))
Just like @saitishmukhametov mentioned before, do resizing in lib/dataset/DemoDataset.py
:
if self.video_flag[self.count]:
# Read video
self.mode = 'video'
ret_val, img0 = self.cap.read()
# **Resize**
img0 = cv2.resize(img0, (self.img_size, self.img_size))
if not ret_val:
self.count += 1
self.cap.release()
if self.count == self.nf: # last video
raise StopIteration
else:
path = self.files[self.count]
self.new_video(path)
ret_val, img0 = self.cap.read()
h0, w0 = img0.shape[:2]
self.frame += 1
print('\n video %g/%g (%g/%g) %s: ' % (self.count + 1, self.nf, self.frame, self.nframes, path), end='')
else:
# Read image
self.count += 1
img0 = cv2.imread(path, cv2.IMREAD_COLOR | cv2.IMREAD_IGNORE_ORIENTATION) # BGR
#img0 = cv2.cvtColor(img0, cv2.COLOR_BGR2RGB)
assert img0 is not None, 'Image Not Found ' + path
print('image %g/%g %s: \n' % (self.count, self.nf, path), end='')
# **Resize**
img0 = cv2.resize(img0, (self.img_size, self.img_size))
h0, w0 = img0.shape[:2]
if not is_demo:
img = cv2.resize(img, (result.shape[1], result.shape[0]), interpolation=cv2.INTER_LINEAR)
else:
img = cv2.resize(img, (result[0].shape[1], result[0].shape[0]), interpolation=cv2.INTER_LINEAR)
img[color_mask != 0] = img[color_mask != 0] * 0.5 + color_seg[color_mask != 0] * 0.5
This will solve your problem
Hey buddy, where do I change this code?
of you solve it? I have the same problem
me too