Exemplo n.º 1
0
def run(panels):
    logger = commands.get_logger(__name__, threading.get_ident())
    try:
        logger.info('Text detection')
        paths = map(lambda panel: panel['path'].as_posix(), panels)
        for (path, texts) in images.text.detect(paths):
            text = ''.join(map(lambda x: x['description'], filter(lambda x: 'locale' in x,texts)))
            logger.info('-> {0}'.format(path))
            logger.info(text)
            db.metadata.update(path, auto_script=text)
        logger.info('Done')
    except Exception as e:
        logger.exception(e)
Exemplo n.º 2
0
def run(panels):
    logger = commands.get_logger(__name__, threading.get_ident())
    try:
        logger.info('Face detection')
        for panel in panels:
            path = panel['path'].as_posix()
            logger.info(path)

            crops = list(images.faces.detect(path))
            for crop in crops:
                logger.info(crop)
            db.faces.update(panel, crops)
        logger.info('Done')
    except Exception as e:
        logger.exception(e)
Exemplo n.º 3
0
def run(id, panels, tags):
    logger = commands.get_logger(__name__, threading.get_ident())
    try:
        logger.info('Learn characters')

        data = []
        for panel in panels:
            for (face, character) in zip(panel['faces'], panel['metadata']['characters']):
                logger.info('%s %s' % (face, character))

                if character in tags:
                    data.append((face.as_posix(), tags.index(character)))

        images.learn.train(logger, db.models.path_for(id).as_posix(), len(tags), data)
        db.models.update(id, tags)
        logger.info('Done')

    except Exception as e:
        logger.exception(e)
Exemplo n.º 4
0
def run(id, panels):
    logger = commands.get_logger(__name__, threading.get_ident())
    try:
        logger.info('Character infer detection')

        tags = db.models.tags(id)
        for panel in panels:
            logger.info(panel['path'])
            auto_characters = []
            for face in panel['faces']:
                logger.info(face)
                prediction = images.learn.infer(db.models.path_for(id).as_posix(), len(tags), face.as_posix())
                tag = tags[prediction]
                logger.info('{0} => {1}'.format(prediction, tag))
                auto_characters.append(tag)
            db.metadata.update(panel['path'].as_posix(), auto_characters=auto_characters)
        logger.info('Done')
    except Exception as e:
        logger.exception(e)
Exemplo n.º 5
0
def run(id, volume, images):
    logger = commands.get_logger(__name__, threading.get_ident())
    try:
        logger.info('Cut {0} {1}'.format(id, volume))

        cut = Cut()

        for (filename, path) in images:
            logger.info('statistics: {0}'.format(filename))
            cut.statistics(path)

        for (filename, path) in images:
            logger.info('crop: {0}'.format(filename))

            for i, image in enumerate(cut.crop(path)):
                logger.info('found: {0} -> {1}'.format(filename, i))
                db.panels.update(id, volume, filename, i, image)

    except Exception as e:
        logger.exception(e)
Exemplo n.º 6
0
def run(id, volume, images):
    logger = commands.get_logger(__name__, threading.get_ident())
    try:
        logger.info('Cut {0} {1}'.format(id, volume))

        cut = Cut()

        for (filename, path) in images:
            logger.info('statistics: {0}'.format(filename))
            cut.statistics(path)

        for (filename, path) in images:
            logger.info('crop: {0}'.format(filename))

            for i, image in enumerate(cut.crop(path)):
                logger.info('found: {0} -> {1}'.format(filename, i))
                db.panels.update(id, volume, filename, i, image)

    except Exception as e:
        logger.exception(e)
Exemplo n.º 7
0
def run(id, panels):
    logger = commands.get_logger(__name__, threading.get_ident())
    try:
        logger.info('Character infer detection')

        tags = db.models.tags(id)
        for panel in panels:
            logger.info(panel['path'])
            auto_characters = []
            for face in panel['faces']:
                logger.info(face)
                prediction = images.learn.infer(
                    db.models.path_for(id).as_posix(), len(tags),
                    face.as_posix())
                tag = tags[prediction]
                logger.info('{0} => {1}'.format(prediction, tag))
                auto_characters.append(tag)
            db.metadata.update(panel['path'].as_posix(),
                               auto_characters=auto_characters)
        logger.info('Done')
    except Exception as e:
        logger.exception(e)