Пример #1
0
def main(args):
    broden_root = Path(args.root).resolve()
    tree = parts.ObjectTree.from_meta_folder(broden_root / 'meta')
    encoder_path, decoder_path = utils.upernet_ckpt(broden_root)
    model = Head3(tree, encoder_path, decoder_path)
    db = upernet_data_pipeline(broden_root)

    metrics = partial(parts.BrodenMetricsClbk,
                      obj_tree=tree,
                      split_func=lambda o: o)

    learn = Learner(
        db,
        model,
        loss_func=Loss(tree),
        callback_fns=metrics,
    )
    learn.split((learn.model.obj_branch, ))
    learn.freeze()

    utils.fit_and_log(learn,
                      'object-P.A',
                      save=args.save,
                      epochs=20,
                      lr=1e-2,
                      pct_start=args.pct_start)
Пример #2
0
def main(args):
    print(args)
    arch = pose.nets[args.resnet]

    if args.cnn_fix:
        instructor = CNNObserver()
        bu_c = 0
    else:
        instructor = SelfObserveInstructor()
        bu_c = 16 * 3

    root = Path(__file__).resolve().parent.parent / 'LIP'
    db = pose.get_data(root, args.size, bs=args.bs)

    self_correct = SelfCorrect()
    pckh = partial(pose.Pckh,
                   niter=3,
                   mean=False,
                   heatmap_func=self_correct.heatmap_func)
    learn = cs.cs_learner(db,
                          arch,
                          instructor,
                          td_c=16,
                          bu_c=bu_c,
                          pretrained=False,
                          embedding=None,
                          add_td_out=True,
                          loss_func=self_correct.loss_func,
                          metrics=self_correct.accuracy,
                          callback_fns=[pckh, DataTime])

    monitor = 'Total_2'
    utils.fit_and_log(learn, args, monitor)
Пример #3
0
def main(args):
    broden_root = Path(args.root).resolve()
    tree = parts.ObjectTree.from_meta_folder(broden_root / 'meta')
    db10 = parts.upernet_data_pipeline(broden_root, csv_file='broden10.csv')
    cls10 = obj_sets[args.obj_set]
    obj10 = [tree.obj_names.index(name) for name in cls10]
    model, instructor = taskmod(broden_root,
                                tree,
                                obj_classes=obj10,
                                full_head=args.full_head)
    if args.fill_ones:
        model.embeddings.apply(init_ones)

    metrics = partial(parts.BinaryBrodenMetrics,
                      obj_tree=tree,
                      thresh=0.5,
                      obj_classes=obj10)
    learn = Learner(db10,
                    model,
                    loss_func=instructor.loss,
                    callbacks=[instructor],
                    callback_fns=metrics)
    learn.split((learn.model.embeddings, ))
    learn.freeze()
    utils.fit_and_log(learn,
                      'object-P.A',
                      save=args.save,
                      epochs=20,
                      lr=args.lr,
                      pct_start=args.pct_start,
                      start_epoch=args.start_epoch)
Пример #4
0
def main(args):
    print(args)
    arch = pose.nets[args.resnet]

    n = args.niter
    instructor = cs.RecurrentInstructor(n)
    pckh = partial(pose.Pckh, niter=n)
    loss = pose.RecurrentLoss(n)

    root = Path(__file__).resolve().parent.parent / 'LIP'
    db = pose.get_data(root, args.size, bs=args.bs)

    lateral = lateral_types[args.lateral]
    learn = cs.cs_learner(db,
                          arch,
                          instructor,
                          td_c=16,
                          pretrained=False,
                          embedding=None,
                          lateral=lateral,
                          add_td_out=args.add_td_out,
                          loss_func=loss,
                          callback_fns=[pckh, DataTime])

    monitor = f'Total_{n - 1}' if n > 1 else 'Total'
    utils.fit_and_log(learn, args, monitor)
Пример #5
0
def main(args):
    broden_root = Path(args.root).resolve()
    tree = parts.ObjectTree.from_meta_folder(broden_root / 'meta')
    encoder_path, decoder_path = utils.upernet_ckpt(broden_root)
    model = cs_head.CSHead2(tree,
                            encoder_path,
                            decoder_path,
                            hidden=args.hidden)
    clbk = cs_head.Head2Clbk(tree)
    db = upernet_data_pipeline(broden_root)

    metrics = partial(parts.BrodenMetricsClbk,
                      obj_tree=tree,
                      split_func=lambda o: (o[0], o[1]))
    clbks = [clbk]
    if not args.train_bn:
        clbks.append(utils.BnFreeze(model.fpn))
    learn = Learner(db,
                    model,
                    loss_func=cs_head.Head2Loss(tree),
                    callbacks=clbks,
                    callback_fns=metrics,
                    train_bn=args.train_bn)
    learn.split((learn.model.embedding, ))
    learn.freeze()

    utils.fit_and_log(learn,
                      'object-P.A',
                      save=args.save,
                      epochs=20,
                      lr=1e-2,
                      pct_start=args.pct_start)
Пример #6
0
def main(args):
    broden_root = Path(args.root).resolve()
    tree = parts.ObjectTree.from_meta_folder(broden_root / 'meta')
    model, instructor = get_model(broden_root, tree, ops[args.op])
    db = upernet_data_pipeline(broden_root)

    metrics = partial(parts.BinaryBrodenMetrics, obj_tree=tree, thresh=0.75)
    clbks = [instructor]
    if not args.train_bn:
        clbks.append(utils.BnFreeze(model.fpn))
    learn = Learner(db, model, loss_func=instructor.loss, callbacks=clbks, callback_fns=metrics, train_bn=args.train_bn)
    learn.split((learn.model.td,))
    learn.freeze()

    utils.fit_and_log(learn, 'object-P.A', save=args.save, epochs=20, lr=1e-2, pct_start=args.pct_start)
Пример #7
0
def main(args):
    broden_root = Path(args.root).resolve()
    tree = parts.ObjectTree.from_meta_folder(broden_root / 'meta')
    db = upernet_data_pipeline(broden_root)
    model, instructor = taskmod(broden_root, tree)
    metrics = partial(parts.BinaryBrodenMetrics, obj_tree=tree, thresh=0.5)
    learn = Learner(db,
                    model,
                    loss_func=instructor.loss,
                    callbacks=[instructor],
                    callback_fns=metrics)
    learn.split((learn.model.embeddings, ))
    learn.freeze()

    utils.fit_and_log(learn,
                      'object-P.A',
                      save=args.save,
                      epochs=20,
                      lr=1e-3,
                      pct_start=args.pct_start)
Пример #8
0
def main(args):
    broden_root = Path(args.root).resolve()
    db = parts.get_data(broden_root, bs=args.bs)
    tree = parts.ObjectTree.from_meta_folder(broden_root / 'meta')
    learn = parts.part_learner(db,
                               models.resnet34,
                               tree,
                               pretrained=args.pretrained,
                               sample_one=args.sample_one)
    lr = args.lr
    if args.lr0 is not None:
        lr = slice(args.lr0, lr)
    utils.fit_and_log(learn,
                      'object-P.A.',
                      save=args.save,
                      epochs=args.epochs,
                      start_epoch=args.start_epoch,
                      lr=lr,
                      wd=args.wd,
                      load=args.load,
                      no_one_cycle=args.no_one_cycle)