-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathnu_gan.py
67 lines (56 loc) · 2.68 KB
/
nu_gan.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
67
import os
import time
import argparse
from utils.experiment import cell_segmentation, cell_representation, image_classification
parser = argparse.ArgumentParser()
parser.add_argument('--task',
choices = ['cell_representation', 'image_classification', 'cell_segmentation'],
help='cell_representation | image_classification | cell_segmentation')
opt = parser.parse_args()
if not (opt.task):
parser.error("specific a task such as '--task cell_representation'")
#for image classification and nuclei segmentation
experiment_root = './experiment/'
positive_images_root= experiment_root + 'data/original/positive_images/'
negative_images_root= experiment_root + 'data/original/negative_images/'
positive_npy_root = experiment_root + 'data/segmented/positive_npy/'
negative_npy_root = experiment_root + 'data/segmented/negative_npy/'
ref_path = experiment_root + 'data/original/reference/BM_GRAZ_HE_0007_01.png'
#cell_level_data
X_train_path = experiment_root + 'data/cell_level_label/X_train.npy'
X_test_path = experiment_root + 'data/cell_level_label/X_test.npy'
y_train_path = experiment_root + 'data/cell_level_label/y_train.npy'
y_test_path = experiment_root + 'data/cell_level_label/y_test.npy'
n_epoch=50
batchsize=10
rand=32
dis=1
dis_category=5
ld = 1e-4
lg = 1e-4
lq = 1e-4
random_seed = 42
save_model_steps=100
intensity = 160 #segmentation intensity
multi_process = True #multi core process for nuclei segmentation
fold = 4
choosing_fold = 1 #cross-validation for classification
time = str(int(time.time()))
if 1- os.path.exists(experiment_root+time):
os.makedirs(experiment_root+time)
os.makedirs(experiment_root+time+'/'+'picture')
os.makedirs(experiment_root+time+'/'+'model')
experiment_root = experiment_root + time + '/'
print('folder_name:'+str(time))
if opt.task == 'cell_representation':
cell_representation(X_train_path, X_test_path, y_train_path, y_test_path, experiment_root,
n_epoch, batchsize, rand, dis, dis_category,
ld, lg, lq, save_model_steps)
if opt.task == 'image_classification':
image_classification(positive_images_root, negative_images_root, positive_npy_root,negative_npy_root,
ref_path, intensity, X_train_path, X_test_path, y_train_path, y_test_path,
experiment_root, multi_process, fold, random_seed, choosing_fold, n_epoch,
batchsize, rand, dis, dis_category, ld, lg, lq, save_model_steps)
if opt.task == 'cell_segmentation':
cell_segmentation(positive_images_root, negative_images_root, positive_npy_root,
negative_npy_root, ref_path, intensity, multi_process)