How to use the kraken.lib.models.load_any function in kraken

To help you get started, we’ve selected a few kraken examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mittagessen / kraken / tests / test_models.py View on Github external
def test_load_any_pyrnn_py3(self):
        """
        Test load_any doesn't load pickled models on python 3
        """
        rnn = models.load_any(os.path.join(resources, 'model.pyrnn.gz'))
github mittagessen / kraken / tests / test_models.py View on Github external
def test_load_clstm(self):
        """
        Tests loading of valid clstm files.
        """
        rnn = models.load_any(os.path.join(resources, 'toy.clstm').encode('utf-8'))
        self.assertIsInstance(rnn, models.TorchSeqRecognizer)
github mittagessen / kraken / kraken / ketos.py View on Github external
Publishes a model on the zenodo model repository.
    """
    import json
    import pkg_resources

    from functools import partial
    from jsonschema import validate
    from jsonschema.exceptions import ValidationError

    from kraken import repo
    from kraken.lib import models

    with pkg_resources.resource_stream(__name__, 'metadata.schema.json') as fp:
        schema = json.load(fp)

    nn = models.load_any(model)

    if not metadata:
        author = click.prompt('author')
        affiliation = click.prompt('affiliation')
        summary = click.prompt('summary')
        description = click.edit('Write long form description (training data, transcription standards) of the model here')
        accuracy_default = None
        # take last accuracy measurement in model metadata
        if 'accuracy' in nn.nn.user_metadata and nn.nn.user_metadata['accuracy']:
           accuracy_default = nn.nn.user_metadata['accuracy'][-1][1] * 100
        accuracy = click.prompt('accuracy on test set', type=float, default=accuracy_default)
        script = [click.prompt('script', type=click.Choice(sorted(schema['properties']['script']['items']['enum'])), show_choices=True)]
        license = click.prompt('license', type=click.Choice(sorted(schema['properties']['license']['enum'])), show_choices=True)
        metadata = {
                'authors': [{'name': author, 'affiliation': affiliation}],
                'summary': summary,