Exemplo n.º 1
0
    def __init__(self, model):
        super(Keras2Emitter, self).__init__()
        from six import string_types as _string_types
        if isinstance(model, _string_types):
            network_path = model
        else:
            network_path = model[0]
            weight_path = model[1]

        self.IR_graph = IRGraph(network_path)
        self.IR_graph.build()
Exemplo n.º 2
0
    def __init__(self, model):
        from six import string_types as _string_types
        super(CaffeEmitter, self).__init__()
        if isinstance(model, _string_types):
            network_path = model
        else:
            network_path = model[0]
            self._load_weights(model[1])

        self.IR_graph = IRGraph(network_path)
        super(CaffeEmitter, self)._build()
Exemplo n.º 3
0
    def __init__(self, model):
        super(PytorchEmitter, self).__init__()
        if isinstance(model, _string_types):
            network_path = model
        else:
            network_path = model[0]
            weight_path = model[1]

        self.init_code = str()
        self.IR_graph = IRGraph(network_path)
        self.IR_graph.build()
        self._load_weights(weight_path)
Exemplo n.º 4
0
    def __init__(self, architecture, weight):
        super(CoreMLEmitter, self).__init__()
        if os.path.exists(architecture) == False:
            raise ValueError("IR architecture file [{}] is not found.".format(architecture))
        else:
            self.IR_graph = IRGraph(architecture)
            self.IR_graph.build()

        if os.path.exists(weight) == False:
            raise ValueError("IR weight file [{}] is not found.".format(weight))
        else:
            self._load_weights(weight)
Exemplo n.º 5
0
    def __init__(self, model):
        from six import string_types as _string_types
        super(CntkEmitter, self).__init__()
        if isinstance(model, _string_types):
            network_path = model
        else:
            network_path = model[0]
            self._load_weights(model[1])

        self.IR_graph = IRGraph(network_path)
        super(CntkEmitter, self)._build()
        self.yolo_parameter = []
        folder = Folder(self.IR_graph, self.weights_dict)
        folder.fold()
Exemplo n.º 6
0
    def __init__(self, model):
        super(TensorflowEmitter, self).__init__()

        from six import string_types as _string_types
        if isinstance(model, _string_types):
            network_path = model
        else:
            network_path = model[0]
            self._load_weights(model[1])

        self.IR_graph = IRGraph(network_path)
        super(TensorflowEmitter, self)._build()

        folder = Folder(self.IR_graph, self.weights_dict)
        folder.fold()
Exemplo n.º 7
0
    def __init__(self, model, ctx='cpu'):
        super(MyPytorchEmitter, self).__init__()
        if isinstance(model, _string_types):
            network_path = model
        else:
            network_path = model[0]
            weight_path = model[1]

        self.ctx = ctx
        self.init_code = str()
        self.IR_graph = IRGraph(network_path)
        self.IR_graph.build()
        self._load_weights(weight_path)

        self.weights_dict = MyPytorchEmitter.convert(self.weights_dict) 

        folder = Folder(self.IR_graph, self.weights_dict)
        folder.fold()
Exemplo n.º 8
0
    def __init__(self, model):
        super(Keras2Emitter, self).__init__()
        from six import string_types as _string_types
        if isinstance(model, _string_types):
            network_path = model
        else:
            network_path = model[0]
            weight_path = model[1]
            self._load_weights(weight_path)

        self.IR_graph = IRGraph(network_path)
        self.IR_graph.build()
        self.yolo_parameter = []
        self.region_parameter = []
        self.layers_codes_count = dict()

        folder = Folder(self.IR_graph, self.weights_dict)
        folder.fold()
Exemplo n.º 9
0
    def __init__(self, model):
        from six import string_types as _string_types
        
        if isinstance(model, _string_types):
            network_path = model
            self.weight_loaded = False
        elif len(model) == 4:
            network_path = model[0]
            weight_path = model[1]
            self.input_shape = model[2]
            self.output_weights_file = model[3]
            self.weights = np.load(weight_path).item()
            self.weight_loaded = True
            self.output_weights = dict()
        else:
            raise ValueError("the # of input arguments [{}] is not supported" % len(model))

        self.IR_graph = IRGraph(network_path)
        self.IR_graph.build()
Exemplo n.º 10
0
    def __init__(self, model):
        super(MXNetEmitter, self).__init__()
        from six import string_types as _string_types

        if isinstance(model, _string_types):
            network_path = model
            self.weight_loaded = False
        elif len(model) == 3:
            network_path = model[0]
            weight_path = model[1]
            self.output_weights_file = model[2]
            self.output_weights = dict()
            self._load_weights(weight_path)
            self.weights = self.weights_dict
        else:
            raise ValueError("the # of input arguments [{}] is not supported" % len(model))

        self.IR_graph = IRGraph(network_path)
        self.IR_graph.build()

        folder = Folder(self.IR_graph, self.weights)
        folder.fold()
    def __init__(self, graphfile, weightfile=None):
        print("Initializing network...")

        self.graphfile = graphfile
        self.weightfile = weightfile

        self.IR_graph = IRGraph(self.graphfile)
        self.IR_graph.build()
        self.IR_graph.model = 1

        if self.weightfile is None:
            logging.info("No weights file loaded\n")
        else:
            logging.info("Load weights...\n")
            try:
                self.weights_dict = np.load(self.weightfile,
                                            allow_pickle=True).item()
            except:
                self.weights_dict = np.load(self.weightfile,
                                            encoding='bytes',
                                            allow_pickle=True).item()

        self.analyze_net()
        print("Network analyzed successfully...\n")