def get_mnist_parsed_args(): args = parsing.parse_args() if not args.dataset in MNIST_DATASETS: raise Exception( NOT_MNIST_EXCEPTION.format(args.dataset, MNIST_DATASETS)) args.image_transformers = parsing.parse_transformers( ['scale_2d', 'grayscale']) args.tensor_transformers = parsing.parse_transformers(['normalize_2d']) args.test_image_transformers = parsing.parse_transformers( ['scale_2d', 'grayscale']) args.test_tensor_transformers = parsing.parse_transformers( ['normalize_2d']) args.epochs = 1 args.max_batches_per_epoch = 100 args.num_classes = 10 args.wrap_model = True args.num_images = 2 return args
from onconet.learn import train import onconet.transformers.factory as transformer_factory import onconet.visualize as visualize import onconet.utils.parsing as parsing import warnings import onconet.learn.state_keeper as state from onconet.utils.get_dataset_stats import get_dataset_stats import onconet.utils.stats as stats import pdb import csv #Constants DATE_FORMAT_STR = "%Y-%m-%d:%H-%M-%S" if __name__ == '__main__': args = parsing.parse_args() if args.ignore_warnings: warnings.simplefilter('ignore') repo = git.Repo(search_parent_directories=True) commit = repo.head.object args.commit = commit.hexsha print("OncoNet main running from commit: \n\n{}\n{}author: {}, date: {}".format( commit.hexsha, commit.message, commit.author, commit.committed_date)) if args.get_dataset_stats: print("\nComputing image mean and std...") args.img_mean, args.img_std = get_dataset_stats(args) print('Mean: {}'.format(args.img_mean)) print('Std: {}'.format(args.img_std))
shuffle=False, num_workers=args.num_workers, drop_last=False, pin_memory=True, collate_fn=ignore_None_collate) for batch in tqdm(data_loader): img = batch['x'] paths = batch['path'] if args.cuda: img = img.cuda() B, C, H, W = img.size() left_half = img[:, :, :, :W//2].contiguous().view(B,-1) right_half = img[:, :, :, W//2:].contiguous().view(B,-1) is_right_aligned = right_half.sum(dim=-1) > left_half.sum(dim=-1) for indx, path in enumerate(paths): image_to_side[path] = bool(is_right_aligned[indx]) return image_to_side if __name__ == "__main__": args = parse_args() image_is_right_side = get_image_to_right_side(args) json.dump(image_is_right_side, open(IMAGE_RIGHT_ALIGNED_PATH,'w'))