Commit 52f1c9f8 authored by Gaetano Raffaele's avatar Gaetano Raffaele
Browse files

ENH: finalizing basic workflow.

No related merge requests found
Showing with 10 additions and 8 deletions
+10 -8
import os import os
import json import json
import pickle import pickle
from moringa import preprocess_s2, run_segmentation from moringa import fetch, preprocess_s2, run_segmentation
from Learning.ObjectBased import ObjectBasedClassifier from Learning.ObjectBased import ObjectBasedClassifier
from Postprocessing import Report from Postprocessing import Report
...@@ -103,12 +103,15 @@ def basic(cfg, runlevel=1, single_step=False): ...@@ -103,12 +103,15 @@ def basic(cfg, runlevel=1, single_step=False):
d = json.load(f) d = json.load(f)
oroot = os.path.join(d['output_path'], d['chain_name']) oroot = os.path.join(d['output_path'], d['chain_name'])
oside = os.path.join(oroot, '_side')
os.makedirs(oside, exist_ok=True)
step = runlevel step = runlevel
# Preprocess timeseries # Preprocess timeseries
ts_lst_pkl = os.path.join(oroot, 'time_series_list.pkl') ts_lst_pkl = os.path.join(oside, 'time_series_list.pkl')
if step == 1: if step == 1:
print("[MORINGA-INFO] : ***** BEGIN STEP {} *****".format(step))
process_timeseries(oroot, d, ts_lst_pkl) process_timeseries(oroot, d, ts_lst_pkl)
step += 1 step += 1
if single_step: if single_step:
...@@ -117,6 +120,7 @@ def basic(cfg, runlevel=1, single_step=False): ...@@ -117,6 +120,7 @@ def basic(cfg, runlevel=1, single_step=False):
# Segmentation # Segmentation
seg = os.path.join(oroot, 'segmentation/{}_obj_layer.tif'.format(d['chain_name'])) seg = os.path.join(oroot, 'segmentation/{}_obj_layer.tif'.format(d['chain_name']))
if step == 2: if step == 2:
print("[MORINGA-INFO] : ***** BEGIN STEP {} *****".format(step))
perform_segmentation(seg, d) perform_segmentation(seg, d)
step += 1 step += 1
if single_step: if single_step:
...@@ -127,6 +131,7 @@ def basic(cfg, runlevel=1, single_step=False): ...@@ -127,6 +131,7 @@ def basic(cfg, runlevel=1, single_step=False):
for cf in d['ref_db']['fields']: for cf in d['ref_db']['fields']:
m_files.append(os.path.join(oroot, 'model/model_{}.pkl'.format(cf))) m_files.append(os.path.join(oroot, 'model/model_{}.pkl'.format(cf)))
if step == 3: if step == 3:
print("[MORINGA-INFO] : ***** BEGIN STEP {} *****".format(step))
train_valid_workflow(seg, ts_lst_pkl, d, m_files) train_valid_workflow(seg, ts_lst_pkl, d, m_files)
step += 1 step += 1
if single_step: if single_step:
...@@ -137,6 +142,7 @@ def basic(cfg, runlevel=1, single_step=False): ...@@ -137,6 +142,7 @@ def basic(cfg, runlevel=1, single_step=False):
for cf in d['ref_db']['fields']: for cf in d['ref_db']['fields']:
map_files.append(os.path.join(oroot, 'maps/{}_map_{}.tif'.format(d['chain_name'],cf))) map_files.append(os.path.join(oroot, 'maps/{}_map_{}.tif'.format(d['chain_name'],cf)))
if step == 4: if step == 4:
print("[MORINGA-INFO] : ***** BEGIN STEP {} *****".format(step))
classify(seg, ts_lst_pkl, m_files, d, map_files) classify(seg, ts_lst_pkl, m_files, d, map_files)
step += 1 step += 1
if single_step: if single_step:
...@@ -147,12 +153,8 @@ def basic(cfg, runlevel=1, single_step=False): ...@@ -147,12 +153,8 @@ def basic(cfg, runlevel=1, single_step=False):
for cf in d['ref_db']['fields']: for cf in d['ref_db']['fields']:
report_fn.append(os.path.join(oroot, 'reports/{}_report_{}.pdf'.format(d['chain_name'],cf))) report_fn.append(os.path.join(oroot, 'reports/{}_report_{}.pdf'.format(d['chain_name'],cf)))
if step == 5: if step == 5:
print("[MORINGA-INFO] : ***** BEGIN STEP {} *****".format(step))
report(map_files, m_files, d, report_fn) report(map_files, m_files, d, report_fn)
print("[MORINGA-INFO] : ***** PROCESS FINISHED *****".format(step))
return return
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment