Beispiel #1
0
def test_detection_dataset():
    from cfgs.config_v2 import add_cfg
    dataset_yaml = '/home/cory/yolo2-pytorch/cfgs/config_voc.yaml'
    exp_yaml = '/home/cory/yolo2-pytorch/cfgs/exps/voc0712/voc0712_baseline.yaml'
    cfg = dict()
    add_cfg(cfg, dataset_yaml)
    add_cfg(cfg, exp_yaml)
    dataset = DetectionDataset(cfg)
    num_workers = 4
    batch_size = 16
    dataloader = torch.utils.data.DataLoader(dataset,
                                             batch_size=batch_size,
                                             shuffle=True,
                                             num_workers=num_workers)

    t0 = time.time()
    for i, data in enumerate(dataloader):
        if i > 100:
            break

        # get the inputs
        inputs, labels = data
        print(i, inputs.size(), labels.size())

        # wrap them in Variable
        inputs, labels = Variable(inputs.cuda()), labels
        import numpy as np
        assert np.sum(inputs.data.cpu().numpy()) > 0
    t1 = time.time()
    print(t1 - t0)
Beispiel #2
0
def voc_ap_main():
    os.environ['CUDA_VISIBLE_DEVICES'] = '0'

    dataset_yaml = '/home/cory/yolo2-pytorch/cfgs/config_voc.yaml'
    exp_yaml = '/home/cory/yolo2-pytorch/cfgs/exps/voc0712/voc0712_baseline_v3_rand.yaml'

    cfg = dict()
    add_cfg(cfg, dataset_yaml)
    add_cfg(cfg, exp_yaml)

    epoch = 160

    model_dir = cfg['train_output_dir']
    model_name = cfg['exp_name']
    model = model_dir + '/' + model_name + '_' + str(epoch) + '.h5'
    # model = '/home/cory/yolo2-pytorch/models/yolo-voc.weights.h5'
    print(model)
    voc_ap(model, cfg)
Beispiel #3
0
def test_detection_dataset():
    from cfgs.config_v2 import add_cfg
    dataset_yaml = '/home/cory/yolo2-pytorch/cfgs/config_voc.yaml'
    exp_yaml = '/home/cory/yolo2-pytorch/cfgs/exps/voc0712/voc0712_baseline.yaml'
    cfg = dict()
    add_cfg(cfg, dataset_yaml)
    add_cfg(cfg, exp_yaml)
    dataset = DetectionDataset(cfg)
    dataloader = torch.utils.data.DataLoader(dataset,
                                             batch_size=16,
                                             shuffle=True,
                                             num_workers=4)
    for i, data in enumerate(dataloader):
        # get the inputs
        print(i)
        inputs, labels = data
        print(inputs.size(), labels.size())

        # wrap them in Variable
        inputs, labels = Variable(inputs), labels
from cfgs.config_v2 import add_cfg
import utils.network as net_utils
from darknet_v3 import Darknet19
from datasets.ImageFileDataset_v2 import ImageFileDataset
from utils.timer import Timer
from train.train_util_v2 import *

# dataset_yaml = '/home/cory/yolo2-pytorch/cfgs/config_kitti.yaml'
# exp_yaml = '/home/cory/yolo2-pytorch/cfgs/exps/kitti_new_2.yaml'
dataset_yaml = '/home/cory/yolo2-pytorch/cfgs/config_voc.yaml'
exp_yaml = '/home/cory/yolo2-pytorch/cfgs/exps/voc0712_template.yaml'

cfg = dict()
# add_cfg(cfg, '/home/cory/yolo2-pytorch/cfgs/config_voc.yaml')
add_cfg(cfg, dataset_yaml)
add_cfg(cfg, exp_yaml)

# data loader
imdb = ImageFileDataset(cfg,
                        ImageFileDataset.preprocess_train,
                        processes=4,
                        shuffle=False,
                        dst_size=None,
                        mode='val')

print('imdb load data succeeded')
net = Darknet19(cfg)

# CUDA_VISIBLE_DEVICES=1
# 20  0.68