process_segment.py 3.8 KB
Newer Older
luroth's avatar
luroth committed
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
from ActiveLearningSegmentation.Workflow import Workflow
from Common import Imagefunctions
import time

def process(date):

    path_RAW = 'O:/UAV/_DATA_/Matrice600/2018/FIP_lot1/' + date + '/RAW'
    path_masks = 'O:/UAV/_Processed_/ETHZ_eschikon_FPWW022_lot1/' + date + '/28m_M600P/image_masks'
    path_upload = 'O:/UAV/_Processed_/ETHZ_eschikon_FPWW022_lot1/' + date + '/28m_M600P/segmentation'

    #path_workspace = 'E:/UAV/_Workspace_/ETHZ_eschikon_FPWW022_lot3_' + date + '_segment'
    path_workspace = 'S:/Processing_/' + date + '_segment'

    # Function to extract global sample id
    def plot_group_label_func(df):
        return df.plot_label.str[:11]

    wfl = Workflow(path_RAW = path_RAW,
                   raw_extension = ".ARW",
                   path_masks = path_masks,
                   path_upload= path_upload,
                   path_workspace = path_workspace,
                   plot_group_label_func = plot_group_label_func,
                   minimum_group_size= 40,
                   sample_type = "soil",
                   border_pixels = 12,
                   read_raw_func = Imagefunctions.read_sonyA9_RAW,
                   enhanced_raw_func = Imagefunctions.enhance_sonyA9_rawpy,
                   preview_func = Imagefunctions.preview_sonyA9_rawpy)

    wfl.prepare_workspace()
    wfl.prepare_descriptors()

    wfl.init_images()
    #wfl.save_masks_to_workspace()

    wfl.init_new_classifier()

    path_training_data = 'O:/UAV/_Processed_/ETHZ_eschikon_FPWW022_lot3/20180404/28m_M600P/segmentation_training/Training1.npy'
    path_training_response_data = 'O:/UAV/_Processed_/ETHZ_eschikon_FPWW022_lot3/20180404/28m_M600P/segmentation_training/Training1_response.npy'
    wfl.load_training_data_from_file(path_training_data, path_training_response_data)

    path_training_data = 'O:/UAV/_Processed_/ETHZ_eschikon_FPWW022_lot3/20180404/28m_M600P/segmentation_training/Training2.npy'
    path_training_response_data = 'O:/UAV/_Processed_/ETHZ_eschikon_FPWW022_lot3/20180404/28m_M600P/segmentation_training/Training2_response.npy'
    wfl.load_training_data_from_file(path_training_data, path_training_response_data, overwrite_existing=False)

    #path_training_data = 'O:/UAV/_Processed_/ETHZ_eschikon_FPWW022_lot3/20180306/28m_M600P/Training.npy'
    #path_training_response_data = 'O:/UAV/_Processed_/ETHZ_eschikon_FPWW022_lot3/20180306/28m_M600P/Training_response.npy'
    #wfl.load_training_data_from_file(path_training_data, path_training_response_data, overwrite_existing=False)

    path_training_data = 'O:/UAV/_Processed_/ETHZ_eschikon_FPWW022_lot3/20180409/28m_M600P/segmentation_training/Training.npy'
    path_training_response_data = 'O:/UAV/_Processed_/ETHZ_eschikon_FPWW022_lot3/20180409/28m_M600P/segmentation_training/Training_response.npy'
    wfl.load_training_data_from_file(path_training_data, path_training_response_data, overwrite_existing=False)


    wfl.train_classifier()

    wfl.segment_images()

    wfl.upload_predictions()

    wfl.remove_workspace()


if __name__ == '__main__':

67
    dates_done = [
luroth's avatar
luroth committed
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
        '20180322',
        '20180325',
        '20180402',
        '20180404',
        '20180406',
        '20180409',
        '20180411',
        '20180413',
        '20180417',
        '20180419',
        '20180420',
        '20180423',
        '20180426',
        '20180427',
        '20180501',
        '20180507',
        '20180509',
        '20180511',
        '20180514',
        '20180518',
        '20180521',
        '20180523',
        '20180525',
        '20180528',
        '20180530',
        '20180601',
        '20180604',
        '20180607',
        '20180611',
        '20180614',
98
99
100
101
        '20180618'
    ]

    dates = [
luroth's avatar
luroth committed
102
103
104
105
106
107
108
109
110
111
112
        '20180623',
        '20180625',
        '20180627',
        '20180629',
        '20180702',
        '20180704'
    ]


    for date in dates:
        process(date)