Esempio n. 1
0
def test_coco():
    import django
    sys.path.append(os.path.dirname(__file__))
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dva.settings")
    django.setup()
    from dvaui.view_shared import handle_uploaded_file
    from dvaapp.tasks import perform_import, perform_region_import, perform_dataset_extraction
    from django.core.files.uploadedfile import SimpleUploadedFile
    from dvaapp.models import TEvent
    for fname in glob.glob('tests/ci/coco*.zip'):
        name = fname.split('/')[-1].split('.')[0]
        f = SimpleUploadedFile(fname,
                               file(fname).read(),
                               content_type="application/zip")
        v = handle_uploaded_file(f, name)
        dt = TEvent.objects.get(video=v, operation='perform_import')
        perform_import(dt.pk)
        dt = TEvent(video=v, operation='perform_dataset_extraction')
        dt.save()
        perform_dataset_extraction(dt.pk)
        shutil.copy("tests/ci/coco_regions/coco_ci_regions.json",
                    "dva/media/ingest/coco_ci_regions.json")
        args = {"path": "/ingest/coco_ci_regions.json"}
        dt = TEvent(video=v, operation='perform_region_import', arguments=args)
        dt.save()
        perform_region_import(dt.pk)
Esempio n. 2
0
def test():
    """
    Run tests by launching tasks

    """
    import django
    sys.path.append(os.path.dirname(__file__))
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dva.settings")
    django.setup()
    from django.core.files.uploadedfile import SimpleUploadedFile
    from dvaui.view_shared import handle_uploaded_file, handle_video_url
    for fname in glob.glob('tests/ci/*.mp4'):
        name = fname.split('/')[-1].split('.')[0]
        f = SimpleUploadedFile(fname, file(fname).read(), content_type="video/mp4")
        handle_uploaded_file(f, name)
    for fname in glob.glob('tests/ci/*.zip'):
        name = fname.split('/')[-1].split('.')[0]
        f = SimpleUploadedFile(fname, file(fname).read(), content_type="application/zip")
        handle_uploaded_file(f, name)
Esempio n. 3
0
def qt():
    """
    Add short videos/datasets and launch default tasks for quick testing
    """
    import django
    sys.path.append(os.path.dirname(__file__))
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dva.settings")
    django.setup()
    from django.core.files.uploadedfile import SimpleUploadedFile
    from dvaui.view_shared import handle_uploaded_file
    for fname in glob.glob('tests/ci/*.mp4'):
        name = fname.split('/')[-1].split('.')[0]
        f = SimpleUploadedFile(fname, file(fname).read(), content_type="application/mp4")
        _ = handle_uploaded_file(f, name)
        break
    for fname in glob.glob('tests/ci/example*.zip'):
        name = fname.split('/')[-1].split('.')[0]
        f = SimpleUploadedFile(fname, file(fname).read(), content_type="application/zip")
        _ = handle_uploaded_file(f, name)
        break
Esempio n. 4
0
def test_framelist():
    import django
    sys.path.append(os.path.dirname(__file__))
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dva.settings")
    django.setup()
    from dvaui.view_shared import handle_uploaded_file
    from dvaapp.tasks import perform_import, perform_frame_download
    from django.core.files.uploadedfile import SimpleUploadedFile
    from dvaapp.models import TEvent
    for fname in glob.glob('tests/ci/framelist.*'):
        name = fname.split('/')[-1].split('.')[0]
        f = SimpleUploadedFile(fname,
                               file(fname).read(),
                               content_type="application/json")
        v = handle_uploaded_file(f, name)
        dt = TEvent.objects.get(video=v, operation='perform_import')
        perform_import(dt.pk)
        for t in TEvent.objects.filter(parent=dt):
            perform_frame_download(t.pk)
Esempio n. 5
0
def ci():
    """
    Perform Continuous Integration testing using Travis

    """
    import django
    sys.path.append(os.path.dirname(__file__))
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dva.settings")
    django.setup()
    import base64
    from django.core.files.uploadedfile import SimpleUploadedFile
    from dvaui.view_shared import handle_uploaded_file, pull_vdn_list \
        , import_vdn_dataset_url
    from dvaapp.models import Video, TEvent, VDNServer, DVAPQL, Retriever, DeepModel
    from django.conf import settings
    from dvaapp.processing import DVAPQLProcess
    from dvaapp.tasks import perform_dataset_extraction, perform_indexing, perform_export, perform_import, \
        perform_retriever_creation, perform_detection, \
        perform_video_segmentation, perform_transformation
    for fname in glob.glob('tests/ci/*.mp4'):
        name = fname.split('/')[-1].split('.')[0]
        f = SimpleUploadedFile(fname,
                               file(fname).read(),
                               content_type="video/mp4")
        handle_uploaded_file(f, name, False)
    if sys.platform != 'darwin':
        for fname in glob.glob('tests/*.mp4'):
            name = fname.split('/')[-1].split('.')[0]
            f = SimpleUploadedFile(fname,
                                   file(fname).read(),
                                   content_type="video/mp4")
            handle_uploaded_file(f, name, False)
        for fname in glob.glob('tests/*.zip'):
            name = fname.split('/')[-1].split('.')[0]
            f = SimpleUploadedFile(fname,
                                   file(fname).read(),
                                   content_type="application/zip")
            handle_uploaded_file(f, name)
    for i, v in enumerate(Video.objects.all()):
        if v.dataset:
            arguments = {'sync': True}
            perform_dataset_extraction(
                TEvent.objects.create(video=v, arguments=arguments).pk)
        else:
            arguments = {'sync': True}
            perform_video_segmentation(
                TEvent.objects.create(video=v, arguments=arguments).pk)
        arguments = {'index': 'inception', 'target': 'frames'}
        perform_indexing(
            TEvent.objects.create(video=v, arguments=arguments).pk)
        if i == 0:  # save travis time by just running detection on first video
            # face_mtcnn
            arguments = {'detector': 'face'}
            dt = TEvent.objects.create(video=v, arguments=arguments)
            perform_detection(dt.pk)
            arguments = {
                'filters': {
                    'event_id': dt.pk
                },
            }
            perform_transformation(
                TEvent.objects.create(video=v, arguments=arguments).pk)
            # coco_mobilenet
            arguments = {'detector': 'coco'}
            dt = TEvent.objects.create(video=v, arguments=arguments)
            perform_detection(dt.pk)
            arguments = {
                'filters': {
                    'event_id': dt.pk
                },
            }
            perform_transformation(
                TEvent.objects.create(video=v, arguments=arguments).pk)
            # inception on crops from detector
            arguments = {
                'index': 'inception',
                'target': 'regions',
                'filters': {
                    'event_id': dt.pk,
                    'w__gte': 50,
                    'h__gte': 50
                }
            }
            perform_indexing(
                TEvent.objects.create(video=v, arguments=arguments).pk)
            # assign_open_images_text_tags_by_id(TEvent.objects.create(video=v).pk)
        temp = TEvent.objects.create(video=v,
                                     arguments={'destination': "FILE"})
        perform_export(temp.pk)
        temp.refresh_from_db()
        fname = temp.arguments['file_name']
        f = SimpleUploadedFile(fname,
                               file("{}/exports/{}".format(
                                   settings.MEDIA_ROOT, fname)).read(),
                               content_type="application/zip")
        vimported = handle_uploaded_file(f, fname)
        perform_import(
            TEvent.objects.create(video=vimported,
                                  arguments={
                                      "source": "LOCAL"
                                  }).pk)
    dc = Retriever()
    args = {}
    args['components'] = 32
    args['m'] = 8
    args['v'] = 8
    args['sub'] = 64
    dc.algorithm = Retriever.LOPQ
    dc.source_filters = {
        'indexer_shasum':
        DeepModel.objects.get(name="inception",
                              model_type=DeepModel.INDEXER).shasum
    }
    dc.arguments = args
    dc.save()
    clustering_task = TEvent()
    clustering_task.arguments = {'retriever_pk': dc.pk}
    clustering_task.operation = 'perform_retriever_creation'
    clustering_task.save()
    perform_retriever_creation(clustering_task.pk)
    query_dict = {
        'process_type':
        DVAPQL.QUERY,
        'image_data_b64':
        base64.encodestring(file('tests/query.png').read()),
        'tasks': [{
            'operation': 'perform_indexing',
            'arguments': {
                'index':
                'inception',
                'target':
                'query',
                'next_tasks': [{
                    'operation': 'perform_retrieval',
                    'arguments': {
                        'count': 20,
                        'retriever_pk':
                        Retriever.objects.get(name='inception').pk
                    }
                }]
            }
        }]
    }
    launch_workers_and_scheduler_from_environment()
    qp = DVAPQLProcess()
    qp.create_from_json(query_dict)
    qp.launch()
    qp.wait()
    server, datasets, detectors = pull_vdn_list(1)
    for k in datasets:
        if k['name'] == 'MSCOCO_Sample_500':
            print 'FOUND MSCOCO SAMPLE'
            import_vdn_dataset_url(VDNServer.objects.get(pk=1), k['url'], None,
                                   k)
Esempio n. 6
0
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dva.settings")
django.setup()
from django.core.files.uploadedfile import SimpleUploadedFile
from dvaui.view_shared import handle_uploaded_file
from dvaapp.models import Video, TEvent, DVAPQL, Retriever, TrainedModel, Export
from django.conf import settings
from dvaapp.processing import DVAPQLProcess
from dvaapp.tasks import perform_dataset_extraction, perform_indexing, perform_export, perform_import, \
    perform_detection, \
    perform_video_segmentation, perform_transformation

if __name__ == '__main__':
    for fname in glob.glob('data/citest*.mp4'):
        name = fname.split('/')[-1].split('.')[0]
        f = SimpleUploadedFile(fname, file(fname).read(), content_type="video/mp4")
        handle_uploaded_file(f, name)
    if settings.DEBUG:
        for fname in glob.glob('data/*.zip'):
            name = fname.split('/')[-1].split('.')[0]
            f = SimpleUploadedFile(fname, file(fname).read(), content_type="application/zip")
            handle_uploaded_file(f, name)
    for i, v in enumerate(Video.objects.all()):
        perform_import(TEvent.objects.get(video=v, operation='perform_import').pk)
        if v.dataset:
            arguments = {'sync': True}
            perform_dataset_extraction(TEvent.objects.create(video=v, arguments=arguments).pk)
        else:
            arguments = {'sync': True}
            perform_video_segmentation(TEvent.objects.create(video=v, arguments=arguments).pk)
        arguments = {'index': 'inception', 'target': 'frames'}
        perform_indexing(TEvent.objects.create(video=v, arguments=arguments).pk)
import django
import sys, os, glob
root_path = os.path.join(os.path.dirname(__file__), '../')
print root_path
sys.path.append(root_path)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dva.settings")
django.setup()
from dvaui.view_shared import handle_uploaded_file
from dvaapp.tasks import perform_import
from django.core.files.uploadedfile import SimpleUploadedFile
from dvaapp.models import TEvent
for fname in glob.glob('../framelist.*'):
    name = fname.split('/')[-1].split('.')[0]
    f = SimpleUploadedFile(fname,
                           file(fname).read(),
                           content_type="application/json")
    v = handle_uploaded_file(f, name)
    perform_import(TEvent.objects.get(video=v, operation='perform_import').pk)