phocnet_trainer.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:phocnet 作者: ssudholt 项目源码 文件源码
def __check_size(self, img):
        '''
        checks if the image accords to the minimum size requirements

        Returns:
            tuple (img, bool):
                 img: the original image if the image size was ok, a resized image otherwise
                 bool: flag indicating whether the image was resized
        '''
        if np.amin(img.shape[:2]) < self.min_image_width_height:
            if np.amin(img.shape[:2]) == 0:
                return None, False
            scale = float(self.min_image_width_height+1)/float(np.amin(img.shape[:2]))
            new_shape = (int(scale*img.shape[0]), int(scale*img.shape[1]))
            new_img = resize(image=img, output_shape=new_shape)
            return new_img, True
        else:
            return img, False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号