Ejemplo n.º 1
0
def setup_env(description="Config file options.", gpus='7'):
    parser = argparse.ArgumentParser(description=description)
    parser.add_argument("opts",
                        help="See qpnet/utils/config.py for all options",
                        default=None,
                        nargs=argparse.REMAINDER)
    args = parser.parse_args()
    _C.merge_from_list(args.opts)
    cfg.freeze()
    from qpnet.utils import logging
    logging.setup_logging()
    logger = logging.get_logger(__name__)
    os.environ["CUDA_VISIBLE_DEVICES"] = gpus
    logger.info(f'CUDA_VISIBLE_DEVICES: {gpus}.')
    if not cv2.useOptimized():
        cv2.setUseOptimized(True)
    logger.info(f'cv2 useOptimized is {cv2.useOptimized()}.')
Ejemplo n.º 2
0
import numpy as np
from tqdm import tqdm
import os
from qpnet.utils import logging

logger = logging.get_logger(__name__)


def calculateCrossRatio_min(rec1, rec2):
    """
    computing cross ratio
    :param rec1: (x0, y0, w0, h0), which reflects
            (top, left, width, height)
    :param rec2: (x1, y1, w1, h1)
    :return: scala value of cross ratio
    It is special!!!
    rec1: grid
    rec2: bbox
    """
    set_grid_x = set(range(rec1[0], rec1[0] + rec1[2]))
    set_grid_y = set(range(rec1[1], rec1[1] + rec1[3]))
    set_bbox_x = set(range(rec2[0], rec2[0] + rec2[2]))
    set_bbox_y = set(range(rec2[1], rec2[1] + rec2[3]))

    special_cross_ratio_x = len(set_grid_x & set_bbox_x) / min(
        len(set_grid_x), len(set_bbox_x))
    special_cross_ratio_y = len(set_grid_y & set_bbox_y) / min(
        len(set_grid_y), len(set_bbox_y))
    special_cross_ratio = min(special_cross_ratio_x, special_cross_ratio_y)
    if special_cross_ratio > 1:
        logger.info('The cross ratio is wrong.')