#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""

@author: J-P Praetorius
@email: jan-philipp.praetorius@leibniz-hki.de or p.e.mueller07@gmail.com

Copyright by Jan-Philipp Praetorius

Research Group Applied Systems Biology - Head: Prof. Dr. Marc Thilo Figge
https://www.leibniz-hki.de/en/applied-systems-biology.html
HKI-Center for Systems Biology of Infection
Leibniz Institute for Natural Product Research and Infection Biology -
Hans Knöll Insitute (HKI)
Adolf-Reichwein-Straße 23, 07745 Jena, Germany

"""


import json
import tensorflow as tf

# own written scripts
import sys
from python import utils
from python import SegNet

device_config = {
  "cpus": "all",
  "gpus": [7],
  "log-device-placement": False
}

# Configure the devices
setup_devices(device_config) # = Empty config = All CPUs, All GPUs

data_id = "7"

model_config = {
  "architecture": "SegNet", # MobileNetV2_pix2pix , SegNet
  "model_type": "segmentation",
  "learning_rate": 0.001,
  "output_model_path": "/asbdata/Philipp/HyphaeVsYeast/models/cross-validation/model_{}/trained-model.hdf5".format(data_id),
  "output_model_json_path": "/asbdata/Philipp/HyphaeVsYeast/models/cross-validation/model_{}/trained-model.json".format(data_id),
  "regularization_method": "GaussianDropout",
  "regularization_lambda": 0.1,
  "weight_regularization": "l2",
  "weight_regularization_lambda": 0.001,
  "image_shape": [512, 512, 3],
  "n_classes": 2,
  "transfer_learning": False # False , True
}
print(model_config)

predict_config = {
  "input_dir": f"/home/jpraetor/Dev/HyphaeVsYeast/deep-learning/cross-validation/data_info/modelID_{model_id}_test_data.csv",
  "output_dir": f"/asbdata/Philipp/HyphaeVsYeast/images/ilastik_segmentation/prediction/SegNet/cross-validation/probability_map/",
  "normalization": "zero_one",
  "extended": True
}

print(predict_config)

# Predict with model
# Here we have to set the model parameter as we disabled saving of the untrained model
predict_data(model_config=model_config, config=predict_config)
