示例#1
0
def get_PennTreeBank(data_dir=None):
    if data_dir is None:
        data_dir = get_dataset_path('ptb_data')
    if not os.path.isfile(os.path.join(data_dir, 'ptb.train.txt')):
        download(TRAIN_URL, data_dir)
        download(VALID_URL, data_dir)
        download(TEST_URL, data_dir)
    word_to_id = tfreader._build_vocab(os.path.join(data_dir, 'ptb.train.txt'))
    data3 = [np.asarray(tfreader._file_to_word_ids(os.path.join(data_dir, fname), word_to_id))
             for fname in ['ptb.train.txt', 'ptb.valid.txt', 'ptb.test.txt']]
    return data3, word_to_id
示例#2
0
def get_PennTreeBank(data_dir=None):
    if data_dir is None:
        data_dir = get_dataset_path('ptb_data')
    if not os.path.isfile(os.path.join(data_dir, 'ptb.train.txt')):
        download(TRAIN_URL, data_dir)
        download(VALID_URL, data_dir)
        download(TEST_URL, data_dir)
    word_to_id = tfreader._build_vocab(os.path.join(data_dir, 'ptb.train.txt'))
    data3 = [
        np.asarray(
            tfreader._file_to_word_ids(os.path.join(data_dir, fname),
                                       word_to_id))
        for fname in ['ptb.train.txt', 'ptb.valid.txt', 'ptb.test.txt']
    ]
    return data3, word_to_id
示例#3
0
                    int(r.class_id), int(r.class_id)
                ),
                "bbox": xyxy_to_xywh([round(float(x), 4) for x in r.box]),
                "score": round(float(r.score), 3),
            }
            for r in results
        ]
        evaluator.add(res)
        if evaluator.cache_exists:
            break

    evaluator.save()


download(
    "http://models.tensorpack.com/FasterRCNN/COCO-MaskRCNN-R50FPN2x.npz",
    "./",
    expect_size=165362754)
with backup_cfg():
    evaluate_rcnn(
        "Mask R-CNN (ResNet-50-FPN, 2x)", "1703.06870", [],
        "COCO-MaskRCNN-R50FPN2x.npz",
    )


download(
    "http://models.tensorpack.com/FasterRCNN/COCO-MaskRCNN-R50FPN2xGN.npz",
    "./",
    expect_size=167363872)
with backup_cfg():
    evaluate_rcnn(
        "Mask R-CNN (ResNet-50-FPN, GroupNorm)", "1803.08494",
示例#4
0
            {
                "image_id": img_id,
                "category_id": category_id_to_coco_id.get(
                    int(r.class_id), int(r.class_id)
                ),
                "bbox": xyxy_to_xywh([round(float(x), 4) for x in r.box]),
                "score": round(float(r.score), 3),
            }
            for r in results
        ]
        evaluator.add(res)
        if evaluator.cache_exists:
            break

    evaluator.save()


download(
    "http://models.tensorpack.com/FasterRCNN/COCO-MaskRCNN-R101FPN9xGNCasAugScratch.npz",
    "./",
    expect_size=355680386)
evaluate_rcnn(
    "Mask R-CNN (ResNet-101-FPN, GN, Cascade)",
    "1811.08883",
    """
FPN.CASCADE=True BACKBONE.RESNET_NUM_BLOCKS=[3,4,23,3] FPN.NORM=GN
BACKBONE.NORM=GN FPN.FRCNN_HEAD_FUNC=fastrcnn_4conv1fc_gn_head
FPN.MRCNN_HEAD_FUNC=maskrcnn_up4conv_gn_head""".split(),
    "COCO-MaskRCNN-R101FPN9xGNCasAugScratch.npz",
)
示例#5
0
 def _download_caffe_meta(self):
     fpath = download(CAFFE_ILSVRC12_URL[0],
                      self.dir,
                      expect_size=CAFFE_ILSVRC12_URL[1])
     tarfile.open(fpath, 'r:gz').extractall(self.dir)