def func_per_iteration(self, data, device, iter=None):
    if (self.config is not None):
        config = self.config
    img = data['data']
    label = data['label']
    name = data['fn']
    if (len(config.eval_scale_array) == 1):
        pred = self.whole_eval(img, None, device)
    else:
        pred = self.sliding_eval(img, config.eval_crop_size, config.eval_stride_rate, device)
    (hist_tmp, labeled_tmp, correct_tmp) = hist_info(config.num_classes, pred, label)
    results_dict = {'hist': hist_tmp, 'labeled': labeled_tmp, 'correct': correct_tmp}
    if (self.save_path is not None):
        fn = (name + '.png')
        cv2.imwrite(os.path.join(self.save_path, fn), pred)
        logger.info(('Save the image ' + fn))
    if ((self.logger is not None) and (iter is not None)):
        colors = self.dataset.get_class_colors()
        image = img
        clean = np.zeros(label.shape)
        comp_img = show_img(colors, config.background, image, clean, label, pred)
        self.logger.add_image('vis', np.swapaxes(np.swapaxes(comp_img, 0, 2), 1, 2), iter)
    print('self.show_prediction = ', self.show_prediction)
    if (self.show_image or self.show_prediction):
        colors = self.dataset.get_class_colors()
        image = img
        clean = np.zeros(label.shape)
        if self.show_image:
            comp_img = show_img(colors, config.background, image, clean, label, pred)
        else:
            comp_img = show_prediction(colors, config.background, image, pred)
        cv2.imwrite(os.path.join(os.path.realpath('.'), self.config.save, 'eval', (name + '.vis.png')), comp_img[:, :, ::(- 1)])
    return results_dict
def func_per_iteration(self, data, device, iter=None):
    if (self.config is not None):
        config = self.config
    img = data['data']
    label = data['label']
    name = data['fn']
    if (len(config.eval_scale_array) == 1):
        pred = self.whole_eval(img, None, device)
    else:
        pred = self.sliding_eval(img, config.eval_crop_size, config.eval_stride_rate, device)
    (hist_tmp, labeled_tmp, correct_tmp) = hist_info(config.num_classes, pred, label)
    results_dict = {'hist': hist_tmp, 'labeled': labeled_tmp, 'correct': correct_tmp}
    if (self.save_path is not None):
        fn = (name + '.png')
        cv2.imwrite(os.path.join(self.save_path, fn), pred)
        logger.info(('Save the image ' + fn))
    if ((self.logger is not None) and (iter is not None)):
        colors = self.dataset.get_class_colors()
        image = img
        clean = np.zeros(label.shape)
        comp_img = show_img(colors, config.background, image, clean, label, pred)
        self.logger.add_image('vis', np.swapaxes(np.swapaxes(comp_img, 0, 2), 1, 2), iter)
    print('self.show_prediction = ', self.show_prediction)
    if (self.show_image or self.show_prediction):
        colors = self.dataset.get_class_colors()
        image = img
        clean = np.zeros(label.shape)
        if self.show_image:
            comp_img = show_img(colors, config.background, image, clean, label, pred)
        else:
            comp_img = show_prediction(colors, config.background, image, pred)
        cv2.imwrite(os.path.join(os.path.realpath('.'), self.config.save, 'eval', (name + '.vis.png')), comp_img[:, :, ::(- 1)])
    return results_dict