__init__.py 3.16 KB
Newer Older
Gabriel Kirsten's avatar
 
Gabriel Kirsten committed
1 2 3 4 5 6 7 8 9 10 11 12 13
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
14 15 16 17 18
    
try:
    from .syntactic import Syntactic
except:
    Syntactic = None
Gabriel Kirsten's avatar
 
Gabriel Kirsten committed
19 20 21 22 23 24 25

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

Gabriel Kirsten's avatar
Gabriel Kirsten committed
26 27 28 29 30 31
try:
    from .cnn_pseudo_label_keras import CNNPseudoLabel
except Exception as e: 
    CNNPseudoLabel = None
    print e.message

32 33 34 35 36 37 38 39

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


Gabriel Kirsten's avatar
 
Gabriel Kirsten committed
40 41 42
__all__ = ["classifier", 
           "cnn_caffe",
           "cnn_keras",
Gabriel Kirsten's avatar
Gabriel Kirsten committed
43
           "cnn_pseudo_label_keras",
44
           "segnet_keras",
45
           "weka_classifiers",
Gilberto Astolfi's avatar
 
Gilberto Astolfi committed
46
           "syntactic"
Gabriel Kirsten's avatar
 
Gabriel Kirsten committed
47 48 49 50 51 52 53 54 55 56 57
           ]


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__,
58
                                CNNKeras is not None, bool, meta=CNNKeras, hidden=CNNKeras is None)],
Gabriel Kirsten's avatar
Gabriel Kirsten committed
59 60
                            ["cnn_pseudo_label_keras", Config("Invalid" if CNNPseudoLabel is None else CNNPseudoLabel.__name__,
                                CNNPseudoLabel is not None, bool, meta=CNNPseudoLabel, hidden=CNNPseudoLabel is None)],
61 62
                            ["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
63
                            ["weka_classifiers", Config("Invalid" if WekaClassifiers is None else WekaClassifiers.__name__,
64 65 66
                                WekaClassifiers is not None, bool, meta=WekaClassifiers, hidden=WekaClassifiers is None)],
                            ["syntactic", Config("Invalid" if Syntactic is None else Syntactic.__name__,
                                Syntactic is not None, bool, meta=Syntactic, hidden=Syntactic is None)]
Gabriel Kirsten's avatar
 
Gabriel Kirsten committed
67 68 69 70 71 72 73 74
                        ] )

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"])
Gabriel Kirsten's avatar
Gabriel Kirsten committed
75
    _classifier_list["cnn_pseudo_label_keras"] = Config.nvl_config(configs["cnn_pseudo_label_keras"], _classifier_list["cnn_pseudo_label_keras"])
76
    _classifier_list["segnet_keras"] = Config.nvl_config(configs["segnet_keras"], _classifier_list["segnet_keras"])
77
    _classifier_list["weka_classifiers"] = Config.nvl_config(configs["weka_classifiers"], _classifier_list["weka_classifiers"])
78
    _classifier_list["syntactic"] = Config.nvl_config(configs["syntactic"], _classifier_list["syntactic"])