本文整理汇总了Python中coco.COCO属性的典型用法代码示例。如果您正苦于以下问题:Python coco.COCO属性的具体用法?Python coco.COCO怎么用?Python coco.COCO使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类coco
的用法示例。
在下文中一共展示了coco.COCO属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_args
# 需要导入模块: import coco [as 别名]
# 或者: from coco import COCO [as 别名]
def parse_args():
parser = ArgumentParser(description="Train Single Shot MultiBox Detector"
" on COCO")
parser.add_argument('--data', '-d', type=str, default='../coco',
help='path to test and training data files')
parser.add_argument('--no-cuda', action='store_true',
help='use available GPUs')
parser.add_argument('--seed', '-s', type=int,
help='manually set random seed for torch')
parser.add_argument('--device', '-did', type=int,
help='device id')
parser.add_argument('--threshold', '-t', type=float, default=0.20,
help='stop training early at threshold')
parser.add_argument('--checkpoint', type=str, default='./pretrained/resnet34-ssd1200.pth',
help='path to model checkpoint file')
parser.add_argument('--image-size', default=[1200,1200], type=int, nargs='+',
help='input image sizes (e.g 1400 1400,1200 1200')
parser.add_argument('--strides', default=[3,3,2,2,2,2], type=int, nargs='+',
help='stides for ssd model must include 6 numbers')
parser.add_argument('--use-fp16', action='store_true')
return parser.parse_args()
示例2: parse_args
# 需要导入模块: import coco [as 别名]
# 或者: from coco import COCO [as 别名]
def parse_args():
parser = argparse.ArgumentParser(description="Upscale COCO dataset")
parser.add_argument('--inputs', '-i', type=str, default='/coco',
help='input directory for coco dataset')
parser.add_argument('--outputs', '-o', type=str, default='/cocoup',
help='output directory for upscaled coco dataset')
parser.add_argument('--images', '-im', type=str, default='val2017',
help='image directory')
parser.add_argument('--annotations', '-a', type=str, default='annotations/instances_val2017.json',
help='annotations directory')
parser.add_argument('--size', required=True, type=int, nargs='+',
help='upscaled image sizes (e.g 300 300, 1200 1200')
parser.add_argument('--format', '-f', type=str, default='jpg',
help='image format')
return parser.parse_args()
示例3: eval_ssd_r34_mlperf_coco
# 需要导入模块: import coco [as 别名]
# 或者: from coco import COCO [as 别名]
def eval_ssd_r34_mlperf_coco(args):
from coco import COCO
# Check that GPUs are actually available
use_cuda = not args.no_cuda and torch.cuda.is_available()
dboxes = dboxes_R34_coco(args.image_size,args.strides)
encoder = Encoder(dboxes)
val_trans = SSDTransformer(dboxes, (args.image_size[0], args.image_size[1]), val=True)
val_annotate = os.path.join(args.data, "annotations/instances_val2017.json")
val_coco_root = os.path.join(args.data, "val2017")
cocoGt = COCO(annotation_file=val_annotate)
val_coco = COCODetection(val_coco_root, val_annotate, val_trans)
inv_map = {v:k for k,v in val_coco.label_map.items()}
ssd_r34 = SSD_R34(val_coco.labelnum,strides=args.strides)
print("loading model checkpoint", args.checkpoint)
od = torch.load(args.checkpoint, map_location=lambda storage, loc: storage)
ssd_r34.load_state_dict(od["model"])
if use_cuda:
ssd_r34.cuda(args.device)
loss_func = Loss(dboxes)
if use_cuda:
loss_func.cuda(args.device)
coco_eval(ssd_r34, val_coco, cocoGt, encoder, inv_map, args.threshold,args.device,use_cuda)
示例4: parse_args
# 需要导入模块: import coco [as 别名]
# 或者: from coco import COCO [as 别名]
def parse_args():
parser = ArgumentParser(description="Train Single Shot MultiBox Detector"
" on COCO")
parser.add_argument('--data', '-d', type=str, default='/coco',
help='path to test and training data files')
parser.add_argument('--epochs', '-e', type=int, default=800,
help='number of epochs for training')
parser.add_argument('--batch-size', '-b', type=int, default=32,
help='number of examples for each iteration')
parser.add_argument('--no-cuda', action='store_true',
help='use available GPUs')
parser.add_argument('--seed', '-s', type=int, default=random.SystemRandom().randint(0, 2**32 - 1),
help='manually set random seed for torch')
parser.add_argument('--threshold', '-t', type=float, default=0.23,
help='stop training early at threshold')
parser.add_argument('--iteration', type=int, default=0,
help='iteration to start from')
parser.add_argument('--checkpoint', type=str, default=None,
help='path to model checkpoint file')
parser.add_argument('--no-save', action='store_true',
help='save model checkpoints')
parser.add_argument('--evaluation', nargs='*', type=int,
default=[40, 50, 55, 60, 65, 70, 75, 80],
help='epochs at which to evaluate')
parser.add_argument('--lr-decay-schedule', nargs='*', type=int,
default=[40, 50],
help='epochs at which to decay the learning rate')
parser.add_argument('--warmup', type=float, default=None,
help='how long the learning rate will be warmed up in fraction of epochs')
parser.add_argument('--warmup-factor', type=int, default=0,
help='mlperf rule parameter for controlling warmup curve')
parser.add_argument('--lr', type=float, default=2.5e-3,
help='base learning rate')
# Distributed stuff
parser.add_argument('--local_rank', default=0, type=int,
help='Used for multi-process training. Can either be manually set ' +
'or automatically set by using \'python -m multiproc\'.')
return parser.parse_args()
示例5: parse_args
# 需要导入模块: import coco [as 别名]
# 或者: from coco import COCO [as 别名]
def parse_args():
parser = ArgumentParser(description="Train Single Shot MultiBox Detector"
" on COCO")
parser.add_argument('--data', '-d', type=str, default='/coco',
help='path to test and training data files')
parser.add_argument('--epochs', '-e', type=int, default=800,
help='number of epochs for training')
parser.add_argument('--batch-size', '-b', type=int, default=32,
help='number of examples for each iteration')
parser.add_argument('--eval-batch-size', type=int, default=32,
help='number of examples for each evaluation iteration')
parser.add_argument('--no-cuda', action='store_true',
help='use available GPUs')
parser.add_argument('--seed', '-s', type=int, default=random.SystemRandom().randint(0, 2**32 - 1),
help='manually set random seed for torch')
parser.add_argument('--threshold', '-t', type=float, default=0.212,
help='stop training early at threshold')
parser.add_argument('--iteration', type=int, default=0,
help='iteration to start from')
parser.add_argument('--checkpoint', type=str, default=None,
help='path to model checkpoint file')
parser.add_argument('--no-save', action='store_true',
help='save model checkpoints')
parser.add_argument('--evaluation', nargs='*', type=int,
default=[120000, 160000, 180000, 200000, 220000, 240000],
help='iterations at which to evaluate')
parser.add_argument('--profile', type=int, default=None)
parser.add_argument('--warmup', type=int, default=None)
parser.add_argument('--warmup-factor', type=int, default=1,
help='mlperf rule parameter for controlling warmup curve')
parser.add_argument('--model-path', type=str, default='./vgg16n.pth')
parser.add_argument('--backbone', type=str, choices=['vgg16', 'vgg16bn', 'resnet18', 'resnet34', 'resnet50'], default='resnet34')
parser.add_argument('--use-larc', action='store_true')
parser.add_argument('--num-workers', type=int, default=4)
parser.add_argument('--use-fp16', action='store_true')
parser.add_argument('--print-interval', type=int, default=20)
parser.add_argument('--jit', action='store_true')
parser.add_argument('--nhwc', action='store_true')
parser.add_argument('--pad-input', action='store_true')
parser.add_argument('--lr', type=float, default=1.25e-3)
parser.add_argument('--decay1', type=int, default=160)
parser.add_argument('--decay2', type=int, default=200)
parser.add_argument('--delay-allreduce', action='store_true')
# Distributed stuff
parser.add_argument('--local_rank', default=0, type=int,
help='Used for multi-process training. Can either be manually set ' +
'or automatically set by using \'python -m multiproc\'.')
return parser.parse_args()
# make sure that arguments are all self-consistent
示例6: cityperson_eval
# 需要导入模块: import coco [as 别名]
# 或者: from coco import COCO [as 别名]
def cityperson_eval(src_pth, annFile, CUT_WH=None,
ignore_uncertain=False, use_iod_for_ignore=False, catIds=[],
use_citypersons_standard=True, tiny_scale=1.0, iou_ths=None, setup_labels=None):
if os.path.isdir(src_pth):
resFile = src_pth + '/' + 'bbox.json'
else:
resFile = src_pth
Params.CITYPERSON_STANDARD = use_citypersons_standard
if use_citypersons_standard:
kwargs = {}
if CUT_WH is None: CUT_WH = (1, 1)
else:
kwargs = {'filter_type': 'size'}
if CUT_WH is None: CUT_WH = (1, 1)
Params.TINY_SCALE = tiny_scale
Params.IOU_THS = iou_ths
kwargs.update({'use_iod_for_ignore': use_iod_for_ignore, 'ignore_uncertain': ignore_uncertain})
kwargs['given_catIds'] = len(catIds) > 0
annType = 'bbox' # specify type here
print('Running demo for *%s* results.' % annType)
# running evaluation
print('CUT_WH:', CUT_WH)
print('use_citypersons_standard:', use_citypersons_standard)
print('tiny_scale:', tiny_scale)
print(kwargs)
res_file = open("results.txt", "w")
Params.CUT_WH = CUT_WH
setupLbl = Params().SetupLbl
for id_setup in range(len(setupLbl)):
if (setup_labels is None) or (setupLbl[id_setup] in setup_labels):
cocoGt = COCO(annFile)
cocoDt = cocoGt.loadRes(resFile)
imgIds = sorted(cocoGt.getImgIds())
cocoEval = COCOeval(cocoGt,cocoDt,annType, **kwargs)
cocoEval.params.imgIds = imgIds
cocoEval.evaluate(id_setup)
cocoEval.accumulate()
cocoEval.summarize(id_setup,res_file)
res_file.close()