YOLOP icon indicating copy to clipboard operation
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.

Open shgrace233 opened this issue 3 years ago • 8 comments

What need to do if want to test images of different sizes? Thanks very much.

shgrace233 avatar Nov 16 '21 02:11 shgrace233

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

timothylimyl avatar Nov 25 '21 07:11 timothylimyl

me too, how to solve it ?

Miaonika avatar Apr 15 '22 08:04 Miaonika

@shgrace233 @timothylimyl @Miaonika did any of you solve it? I have the same problem

callmesora avatar Jun 01 '22 09:06 callmesora

@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))

saitishmukhametov avatar Jun 25 '22 16:06 saitishmukhametov

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]

maxwellhertz avatar Nov 14 '22 15:11 maxwellhertz

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

LuthraBhomik avatar Nov 19 '22 10:11 LuthraBhomik

Hey buddy, where do I change this code?

guodong110 avatar Nov 22 '22 09:11 guodong110

of you solve it? I have the same problem

me too

guodong110 avatar Nov 22 '22 09:11 guodong110