__init__.py 2.2 KB
Newer Older
Gabriel Kirsten's avatar
 
Gabriel Kirsten committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
from .classifier import Classifier

try:
    from .weka_classifiers import WekaClassifiers
except Exception as e: 
    WekaClassifiers = None
    print e.message

try:
    from .cnn_caffe import CNNCaffe
except Exception as e: 
    CNNCaffe = None
    print e.message

try:
    from .cnn_keras import CNNKeras
except Exception as e: 
    CNNKeras = None
    print e.message

21 22 23 24 25 26 27 28

try:
    from .segnet_keras import SEGNETKeras
except Exception as e: 
    SEGNETKeras = None
    print e.message


Gabriel Kirsten's avatar
 
Gabriel Kirsten committed
29 30 31
__all__ = ["classifier", 
           "cnn_caffe",
           "cnn_keras",
32
           "segnet_keras",
Gabriel Kirsten's avatar
 
Gabriel Kirsten committed
33 34 35 36 37 38 39 40 41 42 43 44
           "weka_classifiers"
           ]


from collections import OrderedDict
from util.config import Config


_classifier_list = OrderedDict( [ 
                            ["cnn_caffe", Config("Invalid" if CNNCaffe is None else CNNCaffe.__name__,
                                WekaClassifiers is None and CNNCaffe is not None, bool, meta=CNNCaffe, hidden=CNNCaffe is None)],
                            ["cnn_keras", Config("Invalid" if CNNKeras is None else CNNKeras.__name__,
45 46 47
                                CNNKeras is not None, bool, meta=CNNKeras, hidden=CNNKeras is None)],
                            ["segnet_keras", Config("Invalid" if SEGNETKeras is None else SEGNETKeras.__name__,
                                SEGNETKeras is not None, bool, meta=SEGNETKeras, hidden=SEGNETKeras is None)],                            
Gabriel Kirsten's avatar
 
Gabriel Kirsten committed
48 49 50 51 52 53 54 55 56 57
                            ["weka_classifiers", Config("Invalid" if WekaClassifiers is None else WekaClassifiers.__name__,
                                WekaClassifiers is not None, bool, meta=WekaClassifiers, hidden=WekaClassifiers is None)]
                        ] )

def get_classifier_config():
    return _classifier_list

def set_classifier_config(configs):
    _classifier_list["cnn_caffe"] = Config.nvl_config(configs["cnn_caffe"], _classifier_list["cnn_caffe"])
    _classifier_list["cnn_keras"] = Config.nvl_config(configs["cnn_keras"], _classifier_list["cnn_keras"])
58
    _classifier_list["segnet_keras"] = Config.nvl_config(configs["segnet_keras"], _classifier_list["segnet_keras"])
Gabriel Kirsten's avatar
 
Gabriel Kirsten committed
59
    _classifier_list["weka_classifiers"] = Config.nvl_config(configs["weka_classifiers"], _classifier_list["weka_classifiers"])