Example #1
0
def test_step(epoch, data, cfg, model, device):

    # get raw output; this can be for several layers
    outputs = pytorch_model_outputs(model, data, device)

    # cls metrics
    confmat = get_confmat_from_raw(outputs, data)
    print(confmat)
    acc = get_acc_from_confmat(confmat)
    recall = get_recall_from_confmat(confmat)
    precision = get_precision_from_confmat(confmat)

    if cfg.smoothing:
        sm_confmat = get_smoothed_confmat_from_raw(cfg, outputs, data)
        print(sm_confmat)
        sm_acc = get_acc_from_confmat(sm_confmat)
        sm_recall = get_recall_from_confmat(sm_confmat)
        sm_precision = get_precision_from_confmat(sm_confmat)
    # ap = get_ap_from_raw(outputs,data)
    # mAP = get_map_from_ap(ap,data)

    # similarity metric
    features = get_features_from_raw(outputs)
    print("simmat")
    t = Timer()
    t.tic()
    sim_mat = get_simmat_from_features(features)
    print(sim_mat.shape)
    t.toc()
    print(t)
    print("end [simmat]")

    # store results
    results = edict()
    results.acc = acc
    results.recall = recall
    results.precision = precision
    if cfg.smoothing:
        results.sm_acc = sm_acc
        results.sm_recall = sm_recall
        results.sm_precision = sm_precision
    # results.ap = ap
    # results.mAP = mAP
    print(results)
    results.features = features
    results.sim_mat = sim_mat

    return results
Example #2
0
def image_upload(track_id,
                 tpid,
                 tpe,
                 seq,
                 image_type,
                 content,
                 task_seq='!!!',
                 batch='!!!'):
    if not task_seq:
        task_seq = '!!!'
    if not batch:
        batch = '!!!'
    _timer = Timer()
    _timer.stage_begin('image write')
    if not image_write(track_id, tpid, tpe, seq, image_type, content, task_seq,
                       batch):
        return False
    _timer.stage_begin('set batch')
    if not batch_manager.set_batch(track_id, tpid, tpe, seq, image_type,
                                   batch):
        return False
    _timer.finish()
    logger().debug(_timer.dump())
    return True