Esempio n. 1
0
def fit(image):

    labels = helpers.get_labels()

    try:
        model = load_model(config.package_path + '/ann_models/model/model_11-07-2020_23-54-57.h5')

        prediction = model.predict(image)
        index = np.argmax(prediction)
        print(index)
        label_rec = labels["labels_parser"][str(index)]

        return {
            'label': labels["labels_recognition"][label_rec],
            'prediction': prediction,
            'type': 'not-number'
        }

    except Exception as e:
        raise e
Esempio n. 2
0
from mathreader.helpers import data_structures as DS
from mathreader import helpers
import re
import json
import numpy as np

helpers_labels = helpers.get_labels()
labels = helpers_labels['labels_parser']


class StructuralAnalysis:
    def __init__(self, symbol_list):
        self.symbols = symbol_list

    def analyze(self):

        symbols = self.symbols
        symbols = self.__preprocessing(symbols)
        tree = self.__main_parsing(symbols)
        if not tree:
            return
        tlist = self.__tree_to_list(tree)
        latex = self.__list_to_latex_obj(tlist)

        return {'latex': latex, 'tree': tree, 'tlist': tlist}

    def __preprocessing(self, symbols):
        helpers.debug('[parser.py] preprocessing()')
        xmin_sorted = sorted(symbols, key=lambda i: i['xmin'])
        symbols = xmin_sorted
Esempio n. 3
0
 def get_labels(self):
     labels = helpers.get_labels()
     return labels