本文整理匯總了Python中ssd.build_ssd方法的典型用法代碼示例。如果您正苦於以下問題:Python ssd.build_ssd方法的具體用法?Python ssd.build_ssd怎麽用?Python ssd.build_ssd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ssd
的用法示例。
在下文中一共展示了ssd.build_ssd方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_voc
# 需要導入模塊: import ssd [as 別名]
# 或者: from ssd import build_ssd [as 別名]
def test_voc():
# load net
num_classes = len(VOC_CLASSES) + 1 # +1 background
net = build_ssd('test', 300, num_classes) # initialize SSD
net.load_state_dict(torch.load(args.trained_model))
net.eval()
print('Finished loading model!')
# load data
testset = VOCDetection(args.voc_root, [('2007', 'test')], None, VOCAnnotationTransform())
if args.cuda:
net = net.cuda()
cudnn.benchmark = True
# evaluation
test_net(args.save_folder, net, args.cuda, testset,
BaseTransform(net.size, (104, 117, 123)),
thresh=args.visual_threshold)
示例2: test_voc
# 需要導入模塊: import ssd [as 別名]
# 或者: from ssd import build_ssd [as 別名]
def test_voc():
# load net
num_classes = len(VOC_CLASSES) + 1 # +1 background
net = build_ssd('test',args.model, 300, num_classes) # initialize SSD
net.load_state_dict(torch.load(args.trained_model))
net.eval()
print('Finished loading model!')
# load data
testset = VOCDetection(args.voc_root, [('2007', 'test')], None, VOCAnnotationTransform())
if args.cuda:
net = net.cuda()
cudnn.benchmark = True
# evaluation
test_net(args.save_folder, net, args.cuda, testset,
BaseTransform(net.size, (104, 117, 123)),
thresh=args.visual_threshold)
示例3: test_gtdb
# 需要導入模塊: import ssd [as 別名]
# 或者: from ssd import build_ssd [as 別名]
def test_gtdb(args):
gpu_id = 0
if args.cuda:
gpu_id = helpers.get_freer_gpu()
torch.cuda.set_device(gpu_id)
# load net
num_classes = 2 # +1 background
# initialize SSD
net = build_ssd(args, 'test', exp_cfg[args.cfg], gpu_id, args.model_type, num_classes)
logging.debug(net)
net.to(gpu_id)
net = nn.DataParallel(net)
net.load_state_dict(torch.load(args.trained_model, map_location={'cuda:1':'cuda:0'}))
net.eval()
logging.debug('Finished loading model!')
dataset = GTDBDetection(args, args.test_data, split='test',
transform=BaseTransform(args.model_type, (246,246,246)),
target_transform=GTDBAnnotationTransform())
if args.cuda:
net = net.to(gpu_id)
cudnn.benchmark = True
# evaluation
test_net_batch(args, net, gpu_id, dataset,
BaseTransform(args.model_type, (246,246,246)),
thresh=args.visual_threshold)