コード例 #1
0
def read_flags():
    flags.DEFINE_integer("num_proposals", 3,
                         "How many recognation proposals are shown")
    flags.DEFINE_string(
        "deactivate_touchscreen",
        "",  # e.g. maXTouch Digitizer
        "When given this touchscreen is deactivated (for name see xinput)")
    dafault_model_path = os.path.join(os.path.dirname(__file__), 'data',
                                      'model', 'model.ckpt')
    flags.DEFINE_string("model_path", dafault_model_path, "path of the model")
    return flags.FLAGS
コード例 #2
0
def read_flags():
    flags.DEFINE_string(
        "show_record", "",
        "if a path is provided, it shows this tfrecord")
    flags.DEFINE_boolean(
        "load_cache", False,
        "load all strokes from the pkl file from previous run")
    flags.DEFINE_string(
        "path", "tmp", "folder to save the records")
    flags.DEFINE_integer(
        "max_files", 10**10,
        "the max number of files to read")
    flags.DEFINE_string("my_handwriting_train_path", "data/my_handwriting/train/",
                        "path folder with own examples")
    flags.DEFINE_string("my_handwriting_test_path", "data/my_handwriting/test/",
                        "path folder with own examples")
    return flags.FLAGS
コード例 #3
0
def read_flags():
    flags.DEFINE_string('restore_from', "",
                        "optional ckpt-file to restore-from")
    flags.DEFINE_string('path', "vanilla", "Name of the network")
    flags.DEFINE_string('lstm_sizes', "[120, 120]",
                        "List of LSTM-layer sizes (json)")
    flags.DEFINE_boolean(
        'share_param_first_layer', True,
        "Whether the first LSTM-layer shares parameters"
        "in forward and backward layer")
    flags.DEFINE_integer('epoch_num', 1, "Number of epochs to train")
    flags.DEFINE_integer('steps_per_checkpoint', 100, "")
    #flags.DEFINE_integer(
    #    'num_steps', 10000, "Number of batches to run")
    flags.DEFINE_float('learning_rate', 0.003, "Learning rate for Optimizer")
    flags.DEFINE_boolean('fine_tuning', True,
                         "reduce learning rate to 20% for last epoch")
    #flags.DEFINE_integer(
    #   'num_final_steps', 1000,
    #   "Number of batches to run before learning_rate_fine is used")
    flags.DEFINE_string('data_path', "./records", "filepath to the tfrecords")
    flags.DEFINE_boolean('batch_size', 32, "Size of the training batch")

    return flags.FLAGS
コード例 #4
0
    You should have received a copy of the GNU General Public License
    along with Smart Manuscript.  If not, see <http://www.gnu.org/licenses/>.
"""

from tensorflow.python.platform.app import flags
import os
import glob

from .inkml import InkML, TraceGroup
from .corpus import Corpus, Corpora, TranscriptedStrokes

__author__ = "Daniel Vorberg"
__copyright__ = "Copyright (c) 2017, Daniel Vorberg"
__license__ = "GPL"

flags.DEFINE_string("ibm_ub_path", "data/IBM_UB_1/query/",
                    "path to IBM_UB_1 folder (unzipped)")


class IBMub(InkML):

    TRANSCRIPTION = "Tg_Truth"

    def get_segments(self):
        for trace_group in self._root.childs_of_type(TraceGroup):
            yield TranscriptedStrokes(
                transcription=trace_group.annotation[self.TRANSCRIPTION],
                strokes=trace_group.ink())


def load(path, max_files=None):
    """ return corpora (corpus of all files) of the IBM UB database
コード例 #5
0
    return svg_path


def _read_pdf(filename, is_handwritten=None):
    svg_filename = _pdf_to_svg_tmp(filename)
    return _read_svg(svg_filename, is_handwritten)


def main(svg_filename):
    """ show sample handwritten notes """

    strokes, page_size = load(svg_filename)
    ink = InkPage(strokes, page_size)
    ink.plot_pylab()
    plt.show()

    for line in ink.lines:
        line.plot_pylab()
        plt.show()


if __name__ == "__main__":
    from tensorflow.python.platform.app import flags
    FLAGS = flags.FLAGS
    flags.DEFINE_string(
        "file",
        os.path.join(os.path.dirname(__file__), "data", "sample_text",
                     "The_Zen_of_Python.pdf"),
        "file to show features (either PDF or SVG)")
    main(FLAGS.file)
コード例 #6
0
"""

from tensorflow.python.platform.app import flags
import pylab as plt
import os
import glob
from copy import deepcopy

from .corpus import Corpus, Corpora, TranscriptedStrokes
from .inkml import InkML, TraceView

__author__ = "Daniel Vorberg"
__copyright__ = "Copyright (c) 2017, Daniel Vorberg"
__license__ = "GPL"

flags.DEFINE_string("iam_on_do_path", "data/IAMonDo-db-1.0",
                    "path to IAMonDo-db-1.0 folder (unzipped)")


class IAMonDo(InkML):

    TEXTLINE = "Textline"
    WORD = "Word"
    TRANSCRIPTION = "transcription"
    TYPE = "type"
    CORRECTION = "Correction"

    @staticmethod
    def condition(element, type_):
        def includes_corrections(element):
            child_include_corrections = any(
                next(child.search(includes_corrections), None) is not None