check_trace=True, optimize=args.optimize) if args.action == 'inspect': framework.inspect(network, val_loader, args.artifacts, early_stop=args.early_stop) elif args.action == 'evaluate': callbacks = [PrecRec(), IsicIoU()] framework.test( network, val_loader, loss_fn, callbacks, start_epoch, writer=writer, early_stop=args.early_stop, ) for callback in callbacks: results = callback.get_dict() print(results) for key in results: writer.add_scalar(f'Evaluation/{key}', results[key], start_epoch) elif args.action == 'train': scheduler = torch.optim.lr_scheduler.ReduceLROnPlateau(optim, 'min',
example = next(iter(train_loader))[0].cuda() network = torch.jit.trace(network, example, check_trace=True, optimize=args.optimize) if args.action == 'inspect': framework.inspect(network, val_loader, args.artifacts, early_stop=args.early_stop) elif args.action == 'evaluate': prec_rec = PrecRec() framework.test(network, val_loader, loss_fn, [], logger=logger, callbacks=[prec_rec]) elif args.action == 'train': scheduler = torch.optim.lr_scheduler.ReduceLROnPlateau(optim, 'min', patience=2, verbose=True, cooldown=1) for epoch in range(start_epoch, args.epochs): train_loss = framework.train(network, train_loader, loss_fn, optim,
if not args.load: print('Set start epoch and best score to 0') best_score = 0. start_epoch = 0 if args.action == 'inspect': framework.inspect(network, val_loader, args.artifacts, criteria=criteria, early_stop=args.early_stop) elif args.action == 'evaluate': prec_rec = PrecRec() framework.test(network, val_loader, criteria, logger=logger, callbacks=[prec_rec]) f1, thres = prec_rec.best_f1() print('F1', f1, 'at', thres) elif args.action == 'train': scheduler = torch.optim.lr_scheduler.ReduceLROnPlateau( optim, 'min', patience=2, verbose=True, cooldown=1) for epoch in range(start_epoch, args.epochs): train_loss = framework.train(network, train_loader, loss_fn, optim, epoch,