예제 #1
0
def run_on_photo(photo_id):
    model = LocationModel()
    sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
    from photonix.classifiers.runners import results_for_model_on_photo, get_or_create_tag
    photo, results = results_for_model_on_photo(model, photo_id)

    if photo and results['country']:
        from photonix.photos.models import PhotoTag
        photo.clear_tags(source='C', type='L')
        country_tag = get_or_create_tag(library=photo.library,
                                        name=results['country']['name'],
                                        type='L',
                                        source='C')
        PhotoTag(photo=photo,
                 tag=country_tag,
                 source='C',
                 confidence=1.0,
                 significance=1.0).save()
        if results['city']:
            city_tag = get_or_create_tag(library=photo.library,
                                         name=results['city']['name'],
                                         type='L',
                                         source='C',
                                         parent=country_tag)
            PhotoTag(photo=photo,
                     tag=city_tag,
                     source='C',
                     confidence=0.5,
                     significance=0.5).save()

    return photo, results
예제 #2
0
def run_on_photo(photo_id):
    model = ObjectModel()
    sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
    from photonix.classifiers.runners import results_for_model_on_photo, get_or_create_tag
    photo, results = results_for_model_on_photo(model, photo_id)

    if photo:
        from django.utils import timezone
        from photonix.photos.models import PhotoTag
        photo.clear_tags(source='C', type='O')
        for result in results:
            tag = get_or_create_tag(library=photo.library,
                                    name=result['label'],
                                    type='O',
                                    source='C')
            PhotoTag(photo=photo,
                     tag=tag,
                     source='C',
                     confidence=result['score'],
                     significance=result['significance'],
                     position_x=result['x'],
                     position_y=result['y'],
                     size_x=result['width'],
                     size_y=result['height']).save()
        photo.classifier_object_completed_at = timezone.now()
        photo.classifier_object_version = getattr(model, 'version', 0)
        photo.save()

    return photo, results
예제 #3
0
def run_on_photo(photo_id):
    model = StyleModel()
    sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
    from photonix.classifiers.runners import results_for_model_on_photo, get_or_create_tag
    photo, results = results_for_model_on_photo(model, photo_id)

    if photo:
        from django.utils import timezone
        from photonix.photos.models import PhotoTag
        photo.clear_tags(source='C', type='S')
        for name, score in results:
            tag = get_or_create_tag(library=photo.library,
                                    name=name,
                                    type='S',
                                    source='C')
            PhotoTag(photo=photo,
                     tag=tag,
                     source='C',
                     confidence=score,
                     significance=score).save()
        photo.classifier_style_completed_at = timezone.now()
        photo.classifier_style_version = getattr(model, 'version', 0)
        photo.save()

    return photo, results
예제 #4
0
def run_on_photo(photo_id):
    model = StyleModel()
    sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
    from photonix.classifiers.runners import results_for_model_on_photo, get_or_create_tag
    photo, results = results_for_model_on_photo(model, photo_id)

    if photo and results is not None:
        from photonix.photos.models import PhotoTag
        photo.clear_tags(source='C', type='S')
        for name, score in results:
            tag = get_or_create_tag(library=photo.library, name=name, type='S', source='C')
            PhotoTag(photo=photo, tag=tag, source='C', confidence=score, significance=score).save()

    return photo, results