__init__.py 3.13 KB
Newer Older
Gabriel Kirsten's avatar
 
Gabriel Kirsten committed
1 2 3 4 5 6
from .classifier import Classifier

try:
    from .weka_classifiers import WekaClassifiers
except Exception as e: 
    WekaClassifiers = None
7
    print(e)
Gabriel Kirsten's avatar
 
Gabriel Kirsten committed
8

9

Gabriel Kirsten's avatar
 
Gabriel Kirsten committed
10 11 12 13
try:
    from .cnn_caffe import CNNCaffe
except Exception as e: 
    CNNCaffe = None
14
    print(e)
15 16 17 18 19
    
try:
    from .syntactic import Syntactic
except:
    Syntactic = None
Gabriel Kirsten's avatar
 
Gabriel Kirsten committed
20 21 22 23 24

try:
    from .cnn_keras import CNNKeras
except Exception as e: 
    CNNKeras = None
25
    print(e)
Gabriel Kirsten's avatar
 
Gabriel Kirsten committed
26

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

33 34 35 36 37

try:
    from .segnet_keras import SEGNETKeras
except Exception as e: 
    SEGNETKeras = None
38
    print(e)
39 40


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


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

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
76
    _classifier_list["cnn_pseudo_label_keras"] = Config.nvl_config(configs["cnn_pseudo_label_keras"], _classifier_list["cnn_pseudo_label_keras"])
77
    _classifier_list["segnet_keras"] = Config.nvl_config(configs["segnet_keras"], _classifier_list["segnet_keras"])
78
    _classifier_list["weka_classifiers"] = Config.nvl_config(configs["weka_classifiers"], _classifier_list["weka_classifiers"])
79
    _classifier_list["syntactic"] = Config.nvl_config(configs["syntactic"], _classifier_list["syntactic"])