VITA-Group / FasterSeg

[ICLR 2020] "FasterSeg: Searching for Faster Real-time Semantic Segmentation" by Wuyang Chen, Xinyu Gong, Xianming Liu, Qian Zhang, Yuan Li, Zhangyang Wang
MIT License
525 stars 107 forks source link

The inference speed is too slow #29

Closed haezu closed 4 years ago

haezu commented 4 years ago

Hi. Thank you for releasing the code for the paper. After completing the training, we measured the inference time in the process of testing. But the execution speed is too slow. How do I get the results out of your thesis? What is the problem?

def whole_eval(self, img, output_size, input_size=None, device=None):

        if input_size is not None:
            start = time.perf_counter()
            img, margin = self.process_image(img, input_size)
            end = time.perf_counter()
            print('preprocessing :', end-start, 'seconds')

        else:
            img = self.process_image(img, input_size)

        start = time.perf_counter()

        pred = self.val_func_process(img, device)

        if input_size is not None:
            pred = pred[:, margin[0]:(pred.shape[1] - margin[1]),
                   margin[2]:(pred.shape[2] - margin[3])]

        pred = pred.permute(1, 2, 0)
        pred = pred.cpu().numpy()
        if output_size is not None:
            pred = cv2.resize(pred,
                              (output_size[1], output_size[0]),
                              interpolation=cv2.INTER_LINEAR)

        pred = pred.argmax(2)
        end = time.perf_counter()
        print('prediction :', end-start, 'seconds')

        return pred

image

chenwydj commented 4 years ago

Hi @haezu!

Thank you for your interest in our work!

If you set C.is_test = True in the configure file, then the prediction file (which can be uploaded to Cityscapes official leaderboard) will be generated, which makes the test slow. These files (.png) are saved under the prediction directory.

If you just evaluate on the evaluation set (C.is_eval) it is fast.