@@ -8,6 +8,7 @@ compile_opt idl2
88; + start ENVI with the UI
99e = envi()
1010
11+
1112; Get folders for input and output
1213
1314; + get this directory
@@ -24,8 +25,10 @@ timestamp = (strsplit(timestamp, '.', /extract))[0]
2425modelDir = strjoin ([thisDir, 'models-air' , timestamp], path_sep ())
2526if ~file_test (modelDir, / directory) then file_mkdir , modelDir
2627
28+
2729extension = '.dat'
2830
31+
2932; Where we want the model to go
3033
3134; + best model, updated as we go with lowest validation loss
@@ -34,6 +37,7 @@ bestUri = modelDir + path_sep() + 'best.h5'
3437; + last mode (last epoch of training)
3538lastUri = modelDir + path_sep () + 'last.h5'
3639
40+
3741; Training parameters
3842
3943; + random seed for splitting data
@@ -48,6 +52,7 @@ bpr = 0.3
4852; + how many times we run through all positive examples of our features
4953epochs = 100
5054
55+
5156; Load data and split into training and validation buckets
5257
5358; make list for ENVI DL rasters
@@ -75,6 +80,7 @@ idx = sort(randomu(seed, nFiles))
7580training = rasters[* ]
7681validation = rasters[idx[- nValidation : - 1 ]]
7782
83+
7884; Create our training task and specify model parameters
7985
8086; Get the task from the catalog of ENVITasks
@@ -93,31 +99,41 @@ Task.background_patch_ratio = bpr
9399Task.output_model_uri = bestUri
94100Task.output_last_model_uri = lastUri
95101
102+
96103Task.execute
97104
105+
98106Task.execute
99107
108+
100109Task.execute
101110
111+
102112orig = e.openRaster('D:\luno\sky-sat\mosaics\SkySatScene.ntf' )
103113raster = dlAutoPrepareRaster(orig)
104114e.data.add, raster
105115
116+
106117stop
107118
119+
108120Task.execute
109121
122+
110123Task.execute
111124
125+
112126; Train! Now this will take a while, so don't close VSCode or run any other notebooks.
113127
114128Task.execute
115129
130+
116131; Optionally, classify some of our validation images so we can see what our results look like.
117132
118133; stopped so we dont accidentally process all of our images which will take a while!
119134stop
120135
136+
121137; Specify the output folder and open our model
122138
123139; + specify output folder
@@ -126,11 +142,13 @@ validationDir = modelDir + path_sep() + 'validation'
126142; make sure it exists
127143if ~file_test (validationDir, / directory) then file_mkdir , validationDir
128144
145+
129146; Open our model!
130147
131148; + restore the model to process our data with
132149model = ENVITensorFlowObjectModel(lastUri)
133150
151+
134152; Process our data!
135153
136154; specify the number of files to process
@@ -166,4 +184,5 @@ foreach file, validationUris, i do begin
166184 ; clean up
167185 raster.close
168186endforeach
187+
169188end
0 commit comments