Esempio n. 1
0
)
print(opt)
random.seed(opt.manualSeed)
torch.manual_seed(opt.manualSeed)
if opt.gpu:
    torch.cuda.manual_seed_all(opt.manualSeed)

model = locate("models.%s" % opt.model)(opt)
if opt.load:
    model.load(opt.load)
if opt.gpu:
    model.gpu()

print("n parameters: %d" % sum([m.numel() for m in model.parameters()]))

viz = utils.Viz(opt)


def process_batch(batch, loss, i, k, set_, t0):
    """Optimization step.

    batch = [input, target]: contains data for optim step [input, target]
    loss: dict containing statistics about optimization
    i: epoch
    k: index of the current batch
    set_: type of batch (\"train\" or \"dev\")
    t0: time of the beginning of epoch
    """

    nbatch = vars(opt)["nbatch_" + set_]
    res = model.step(batch, set_)
Esempio n. 2
0
    opt = json.loads(data[0])
    opt['p_red'] = 0
    opt['mask_object'] = opt_test.mask_object
    print(opt)
    opt = utils.to_namespace(opt)
    opt.bsz = opt.m
    opt.count = opt_test.count
    model = locate('models.%s' %opt.model)(opt, test=True)
    model.load(opt_test.load)
    if opt_test.gpu:
        model.gpu()
    if opt_test.eval:
        model.eval()
    else:
        print('WARNING: no call to eval()')
    viz = utils.Viz(opt_test)
    viz_output = utils.Viz(opt_test)
else:
    assert opt_test.load_scores

def process_batch(batch, j, t0):
    """Compute score for every frames in a video (which is also a batch).

    batch = [input, target]: all frames in the video
    j: index of the video
    t0: time when the test started
    """
    nbatch = vars(opt)['nbatch_test']
    frame_scores = np.zeros((opt.m, 4))
    d3, d4 = batch[0].size(3), batch[0].size(4)
    for i in range(opt.bsz):