def correct_yolo_boxes(boxes, image_h, image_w, net_h, net_w):
    if ((float(net_w) / image_w) < (float(net_h) / image_h)):
        new_w = net_w
        new_h = ((image_h * net_w) / image_w)
    else:
        new_h = net_w
        new_w = ((image_w * net_h) / image_h)
    for i in range(len(boxes)):
        (x_offset, x_scale) = ((((net_w - new_w) / 2.0) / net_w), (float(new_w) / net_w))
        (y_offset, y_scale) = ((((net_h - new_h) / 2.0) / net_h), (float(new_h) / net_h))
        boxes[i].xmin = int((((boxes[i].xmin - x_offset) / x_scale) * image_w))
        boxes[i].xmax = int((((boxes[i].xmax - x_offset) / x_scale) * image_w))
        boxes[i].ymin = int((((boxes[i].ymin - y_offset) / y_scale) * image_h))
        boxes[i].ymax = int((((boxes[i].ymax - y_offset) / y_scale) * image_h))
def correct_yolo_boxes(boxes, image_h, image_w, net_h, net_w):
    if ((float(net_w) / image_w) < (float(net_h) / image_h)):
        new_w = net_w
        new_h = ((image_h * net_w) / image_w)
    else:
        new_h = net_w
        new_w = ((image_w * net_h) / image_h)
    for i in range(len(boxes)):
        (x_offset, x_scale) = ((((net_w - new_w) / 2.0) / net_w), (float(new_w) / net_w))
        (y_offset, y_scale) = ((((net_h - new_h) / 2.0) / net_h), (float(new_h) / net_h))
        boxes[i].xmin = int((((boxes[i].xmin - x_offset) / x_scale) * image_w))
        boxes[i].xmax = int((((boxes[i].xmax - x_offset) / x_scale) * image_w))
        boxes[i].ymin = int((((boxes[i].ymin - y_offset) / y_scale) * image_h))
        boxes[i].ymax = int((((boxes[i].ymax - y_offset) / y_scale) * image_h))