-
Notifications
You must be signed in to change notification settings - Fork 26
/
Config.py
66 lines (57 loc) · 2.11 KB
/
Config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# -*- coding: utf-8 -*-
import os
import torch
import time
import ml_collections
## PARAMETERS OF THE MODEL
save_model = True
tensorboard = True
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
use_cuda = torch.cuda.is_available()
seed = 666
os.environ['PYTHONHASHSEED'] = str(seed)
cosineLR = True # Use cosineLR or not
n_channels = 3
n_labels = 1 # MoNuSeg & Covid19
epochs = 2000
img_size = 224
print_frequency = 1
save_frequency = 5000
vis_frequency = 10
early_stopping_patience = 50
pretrain = False
task_name = 'MoNuSeg'
# task_name = 'Covid19'
learning_rate = 1e-3 # MoNuSeg: 1e-3, Covid19: 3e-4
batch_size = 2 # For LViT-T, 2 is better than 4
model_name = 'LViT'
# model_name = 'LViT_pretrain'
train_dataset = './datasets/' + task_name + '/Train_Folder/'
val_dataset = './datasets/' + task_name + '/Val_Folder/'
test_dataset = './datasets/' + task_name + '/Test_Folder/'
task_dataset = './datasets/' + task_name + '/Train_Folder/'
session_name = 'Test_session' + '_' + time.strftime('%m.%d_%Hh%M')
save_path = task_name + '/' + model_name + '/' + session_name + '/'
model_path = save_path + 'models/'
tensorboard_folder = save_path + 'tensorboard_logs/'
logger_path = save_path + session_name + ".log"
visualize_path = save_path + 'visualize_val/'
##########################################################################
# CTrans configs
##########################################################################
def get_CTranS_config():
config = ml_collections.ConfigDict()
config.transformer = ml_collections.ConfigDict()
config.KV_size = 960 # KV_size = Q1 + Q2 + Q3 + Q4
config.transformer.num_heads = 4
config.transformer.num_layers = 4
config.expand_ratio = 4 # MLP channel dimension expand ratio
config.transformer.embeddings_dropout_rate = 0.1
config.transformer.attention_dropout_rate = 0.1
config.transformer.dropout_rate = 0
config.patch_sizes = [16, 8, 4, 2]
config.base_channel = 64 # base channel of U-Net
config.n_classes = 1
return config
# used in testing phase, copy the session name in training phase
# test_session = "Test_session_05.23_14h19" # dice=79.98, IoU=66.83