from pathlib import Path from utils_model import train_resnet from utils import (get_classes, get_log_csv_name) # Training the ResNet. print("\n\n+++++ Running 3_train.py +++++") train_resnet( batch_size=config.args.batch_size, checkpoints_folder=Path('checkpoints_easy10'), classes=config.classes, color_jitter_brightness=config.args.color_jitter_brightness, color_jitter_contrast=config.args.color_jitter_contrast, color_jitter_hue=config.args.color_jitter_hue, color_jitter_saturation=config.args.color_jitter_saturation, device=config.device, learning_rate=config.args.learning_rate, learning_rate_decay=config.args.learning_rate_decay, log_csv=get_log_csv_name(log_folder=Path('logs/easy10')), num_classes=config.num_classes, num_layers=config.args.num_layers, num_workers=config.args.num_workers, path_mean=config.path_mean, path_std=config.path_std, pretrain=config.args.pretrain, resume_checkpoint=True, resume_checkpoint_path=Path('checkpoints/resnet18_e10_va0.55588.pt'), save_interval=config.args.save_interval, num_epochs=config.args.num_epochs, train_folder=Path('data/voc_trainval_easy_0.1/'), weight_decay=config.args.weight_decay) print("+++++ Finished running 3_train.py +++++\n\n")
from utils import (get_classes, get_log_csv_name, get_log_csv_train_order) from utils_model import train_resnet device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") path_mean, path_std = ([ 0.40853017568588257, 0.4573926329612732, 0.48035722970962524 ], [0.28722450137138367, 0.27334490418434143, 0.2799932360649109]) exp_num = 43 # Named with date and time. train_folder = Path( "/home/brenta/scratch/jason/data/imagenet/grad/first_test/") log_folder = Path("/home/brenta/scratch/jason/logs/imagenet/grad_cl/exp_" + str(exp_num)) log_csv = get_log_csv_name(log_folder=log_folder) train_order_csv = get_log_csv_train_order(log_folder=log_folder) classes = get_classes(train_folder.joinpath("train")) num_classes = len(classes) # Training the ResNet. print("\n\n+++++ Running 3_train.py +++++") train_resnet( batch_size=256, checkpoints_folder=Path( "/home/brenta/scratch/jason/checkpoints/image_net/grad_cl/exp_" + str(exp_num)), classes=classes, color_jitter_brightness=0, color_jitter_contrast=0, color_jitter_hue=0,
classes = get_classes(folder=args.all_wsi) num_classes = len(classes) # This is the input for model training, automatically built. train_patches = args.train_folder.joinpath("train") val_patches = args.train_folder.joinpath("val") # Compute the mean and standard deviation for the given set of WSI for normalization. path_mean, path_std = compute_stats(folderpath=args.all_wsi, image_ext=args.image_ext) # Only used is resume_ is True. resume_checkpoint_path = args.checkpoints_folder.joinpath(args.checkpoint_file) # Named with date and time. log_csv = get_log_csv_name(log_folder=args.log_folder) # Does nothing if auto_select is True. eval_model = args.checkpoints_folder.joinpath(args.checkpoint_file) # Find the best threshold for filtering noise (discard patches with a confidence less than this threshold). threshold_search = (0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9) # For visualization. # This order is the same order as your sorted classes. colors = ("red", "white", "blue", "green", "purple", "orange", "black", "pink", "yellow") # Print the configuration. # Source: https://stackoverflow.com/questions/44689546/how-to-print-out-a-dictionary-nicely-in-python/44689627 # chr(10) and chr(9) are ways of going around the f-string limitation of