示例#1
0
    def _download(self, root):

        if not os.path.isdir("{root}/wikitext-103".format(root=self.root)):
            archive_dict = ARCHIVE_DICT["full"]
            download_and_extract_archive(
                archive_dict["url"],
                self.root,
                extract_root=self.root,
                md5=archive_dict["md5"],
            )

        if not os.path.isfile(self.file):
            file_zip = os.path.join(root, "wikitext-103-v1.zip")

            if os.path.isfile(file_zip):
                extract_archive(from_path=file_zip, to_path=root)
示例#2
0
    def _download(self, root, annFile):
        if not os.path.isdir(root) or os.path.isdir(annFile):
            if '2017' in root:
                image_dir_zip = os.path.join(up(root), 'val2017.zip')
            elif '2014' in root:
                image_dir_zip = os.path.join(up(root), 'val2014.zip')

            if '2017' in annFile:
                annotations_dir_zip = os.path.join(
                    up(up(annFile)), 'annotations_trainval2017.zip')
            elif '2014' in annFile:
                annotations_dir_zip = os.path.join(
                    up(up(annFile)), 'annotations_trainval2014.zip')

            if os.path.isfile(image_dir_zip) and os.path.isfile(
                    annotations_dir_zip):
                extract_archive(from_path=image_dir_zip, to_path=up(root))
                extract_archive(from_path=annotations_dir_zip,
                                to_path=up(root))
示例#3
0
    def _download(self, root, annFile):
        if not os.path.isdir(root) or not os.path.isdir(annFile):
            if "2017" in root:
                image_dir_zip = os.path.join(up(root), "val2017.zip")
            elif "2014" in root:
                image_dir_zip = os.path.join(up(root), "val2014.zip")
            else:
                image_dir_zip = None

            if "2017" in annFile:
                annotations_dir_zip = os.path.join(
                    up(up(annFile)), "annotations_trainval2017.zip")
            elif "2014" in annFile:
                annotations_dir_zip = os.path.join(
                    up(up(annFile)), "annotations_trainval2014.zip")
            else:
                annotations_dir_zip = None

            if (image_dir_zip is not None and os.path.isfile(image_dir_zip)
                    and annotations_dir_zip is not None
                    and os.path.isfile(annotations_dir_zip)):
                extract_archive(from_path=image_dir_zip, to_path=up(root))
                extract_archive(from_path=annotations_dir_zip,
                                to_path=up(root))
示例#4
0
    def _download(self, root):
        if not os.path.isfile(self.file):
            file_zip = os.path.join(root, "CoNLL2003.zip")

            if os.path.isfile(file_zip):
                extract_archive(from_path=file_zip, to_path=root)
示例#5
0
import copy
import mmcv
import torch
import torch.distributed as dist
from mmcv.runner import load_checkpoint, get_dist_info
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel

from mmdet.apis import init_dist
from mmdet.core import coco_eval, wrap_fp16_model
from mmdet.datasets import build_dataloader, get_dataset
from mmdet.models import build_detector

# Extract val2017 zip
from torchbench.utils import extract_archive
image_dir_zip = osp.join('./.data/vision/coco', 'val2017.zip')
extract_archive(from_path=image_dir_zip, to_path='./.data/vision/coco')


def xyxy2xywh(bbox):
    _bbox = bbox.tolist()
    return [
        _bbox[0],
        _bbox[1],
        _bbox[2] - _bbox[0] + 1,
        _bbox[3] - _bbox[1] + 1,
    ]


def proposal2json(dataset, results):
    json_results = []
    for idx in range(len(dataset)):