#print (labels)
dirName = 'D:\\xampp\\htdocs\\mtlbl\\webpage\\models\\' + model_name

#os.mkdir(dirName)

model_path = dirName + '\\' + model_name
scaler_path = dirName + '\\scaler_' + model_name
keras_path =  dirName + '\\keras_'+  model_name + '.h5'

#print (model_path)
#print (keras_path)
#print (scaler_path)

from magpie import Magpie

magpie = Magpie()

magpie = Magpie(
   keras_model=keras_path,
  word2vec_model=model_path,
 scaler= scaler_path,
labels = labelsa
)
#filePath = 'D:\\xampp\\htdocs\\mtlbl\\webpage\\admin\\classify' + model_name + '\\' + '.txt'
path= 'D:\\xampp\\htdocs\\mtlbl\\webpage\\admin\\classify\\' + model_name + '\\' + val
#print(path)
print (magpie.predict_from_file(path)) #test

#magpie.predict_from_text('Manchester United vs Chelsea')

Esempio n. 2
0
from __future__ import print_function
from magpie import Magpie
import os

dir_path = os.path.dirname(os.path.realpath(os.getcwd()))
dir_path = os.path.join(dir_path, 'text-classification')
labels = open('thread_labels.labels', 'r').read().splitlines()
magpie = Magpie(keras_model='saved_data/model_main',
                word2vec_model='saved_data/word2_vec_model',
                scaler='saved_data/scaler',
                labels=labels)

result = magpie.predict_from_file('test.txt')