Exemple #1
0
    def loadModelMulti(self, modelPath):

        import h5py
        import json
        from neuralnets.keraslayers.ChainCRF import create_custom_objects

        model = keras.models.load_model(modelPath, custom_objects=create_custom_objects())

        with h5py.File(modelPath, 'r') as f:
            modelName = json.loads(f.attrs['modelName'].decode('utf-8'))
            mappings = json.loads(f.attrs['mappings'].decode('utf-8'))
            self.params = json.loads(f.attrs['params'].decode('utf-8'))
            labelKey = json.loads(f.attrs['labelKey'].decode('utf-8'))
            
        self.model = model
        self.setMappings(None, mappings)
Exemple #2
0
    def loadModel(self, modelPath):
        import h5py
        import json
        from neuralnets.keraslayers.ChainCRF import create_custom_objects
        
        model = keras.models.load_model(modelPath, custom_objects=create_custom_objects())

        with h5py.File(modelPath, 'r') as f:
            mappings = json.loads(f.attrs['mappings'])
            if 'additionalFeatures' in f.attrs:
                self.additionalFeatures = json.loads(f.attrs['additionalFeatures'])
                
            if 'maxCharLen' in f.attrs:
                if f.attrs['maxCharLen'] != "None":
                    self.maxCharLen = int(f.attrs['maxCharLen'])
            
        self.model = model        
        self.setMappings(None, mappings)