utils.py 文件源码

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

项目:chainer-object-detection 作者: dsanno 项目源码 文件源码
def reshape_to_yolo_size(img):
    input_width, input_height = img.size
    min_pixel = 320.0
    #max_pixel = 608
    max_pixel = 1024.0

    min_edge = np.minimum(input_width, input_height)
    if min_edge < min_pixel:
        input_width *= min_pixel / min_edge
        input_height *= min_pixel / min_edge
    max_edge = np.maximum(input_width, input_height)
    if max_edge > max_pixel:
        input_width *= max_pixel / max_edge
        input_height *= max_pixel / max_edge

    input_width = int(input_width / 32.0 + round(input_width % 32 / 32.0)) * 32
    input_height = int(input_height / 32.0 + round(input_height % 32 / 32.0)) * 32
    img = img.resize((input_width, input_height))

    return img
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号