How to use the esper.stdlib.qs_to_result function in esper

To help you get started, we’ve selected a few esper 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 scanner-research / esper-tv / app / esper / queries.py View on Github external
def audio_labels():
    from query.models import Speaker
    from esper.stdlib import qs_to_result
    return qs_to_result(Speaker.objects.all(), group=True, limit=10000)
github scanner-research / esper-tv / app / esper / queries.py View on Github external
def cars():
    from query.models import Object
    from esper.stdlib import qs_to_result
    return qs_to_result(Object.objects.filter(label=3, probability__gte=0.9))
github scanner-research / esper-tv / app / esper / queries.py View on Github external
def segments_about_immigration():
    from query.models import Segment
    from esper.stdlib import qs_to_result
    return qs_to_result(
        Segment.objects.filter(
            labeler__name='haotian-segments',
            things__type__name='topic',
            things__name='immigration'))
github scanner-research / esper-tv / app / esper / queries.py View on Github external
start = random.randint(0, v.num_frames - dur - 1)
            end = start + dur
            in_commercial = False
            for c in commercials:
                minf, maxf = (c['min_frame'], c['max_frame'])
                if (minf <= start and start <= max) or (minf <= end and end <= maxf) \
                    or (start <= minf and minf <= end and start <= maxf and maxf <= end):
                    in_commercial = True
                    break
            if not in_commercial:
                break
        else:
            continue
        conds.append({'video': v, 'min_frame__gte': start, 'max_frame__lte': end})

    return qs_to_result(
        Speaker.objects.filter(labeler__name='lium').filter(
            reduce(lambda a, b: a | b, [Q(**c) for c in conds])),
        group=True,
        limit=None)
github scanner-research / esper-tv / app / esper / queries.py View on Github external
def all_faces():
    from query.models import Face
    from esper.stdlib import qs_to_result
    return qs_to_result(Face.objects.all(), stride=1000)
github scanner-research / esper-tv / app / esper / queries.py View on Github external
def segments_about_donald_trump():
    from query.models import Segment
    from esper.stdlib import qs_to_result
    return qs_to_result(
        Segment.objects.filter(
            labeler__name='haotian-segments',
            things__type__name='person',
            things__name='donald trump'))
github scanner-research / esper-tv / app / esper / queries.py View on Github external
from query.models import FaceIdentity
    from esper.stdlib import qs_to_result
    from esper.major_canonical_shows import MAJOR_CANONICAL_SHOWS

    name='hillary clinton'

    results = []
    for show in sorted(MAJOR_CANONICAL_SHOWS):
        qs = FaceIdentity.objects.filter(
            identity__name=name,
            face__shot__video__show__canonical_show__name=show,
            probability__gt=0.9
        )
        if qs.count() > 0:
            results.append(
                (show, qs_to_result(qs, shuffle=True, limit=10))
            )
    return group_results(results)
github scanner-research / esper-tv / app / esper / queries.py View on Github external
def positive_segments():
    from query.models import Segment
    from esper.stdlib import qs_to_result
    return qs_to_result(
        Segment.objects.filter(labeler__name='haotian-segments',
                               polarity__isnull=False).order_by('-polarity'))
github scanner-research / esper-tv / app / esper / queries.py View on Github external
def not_handlabeled():
    from query.models import Labeler, Tag, FaceGender
    from esper.stdlib import qs_to_result
    import random
    l = Labeler.objects.get(name='rudecarnie')
    t = Tag.objects.get(name='handlabeled-face:labeled')
    i = random.randint(0, FaceGender.objects.aggregate(Max('id'))['id__max'])
    return qs_to_result(
        FaceGender.objects.filter(labeler=l, id__gte=i).exclude(
            Q(face__frame__tags=t)
            | Q(face__shot__in_commercial=True)
            | Q(face__shot__video__commercials_labeled=False)
            | Q(face__shot__isnull=True)),
        stride=1000)
github scanner-research / esper-tv / app / esper / queries.py View on Github external
def negative_segments():
    from query.models import Segment
    from esper.stdlib import qs_to_result
    return qs_to_result(
        Segment.objects.filter(labeler__name='haotian-segments',
                               polarity__isnull=False).order_by('polarity'))