def ci(): """ Used in conjunction with travis for Continuous Integration testing :return: """ 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 dvaapp.views import handle_uploaded_file, handle_youtube_video, create_query from dvaapp.models import Video, Clusters,IndexEntries,TEvent from django.conf import settings from dvaapp.tasks import extract_frames, perform_face_indexing, inception_index_by_id, perform_ssd_detection_by_id,\ perform_yolo_detection_by_id, inception_index_ssd_detection_by_id, export_video_by_id, import_video_by_id,\ inception_query_by_image, perform_clustering, assign_open_images_text_tags_by_id 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) 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) handle_youtube_video('tomorrow never dies', 'https://www.youtube.com/watch?v=gYtz5sw98Bc') for i,v in enumerate(Video.objects.all()): extract_frames(TEvent.objects.create(video=v).pk) inception_index_by_id(TEvent.objects.create(video=v).pk) if i ==0: # save travis time by just running detection on first video perform_ssd_detection_by_id(TEvent.objects.create(video=v).pk) perform_yolo_detection_by_id(TEvent.objects.create(video=v).pk) perform_face_indexing(v.pk) inception_index_ssd_detection_by_id(TEvent.objects.create(video=v).pk) assign_open_images_text_tags_by_id(TEvent.objects.create(video=v).pk) fname = export_video_by_id(TEvent.objects.create(video=v,event_type=TEvent.EXPORT).pk) f = SimpleUploadedFile(fname, file("{}/exports/{}".format(settings.MEDIA_ROOT,fname)).read(), content_type="application/zip") vimported = handle_uploaded_file(f, fname) import_video_by_id(TEvent.objects.create(video=vimported).pk) dc = Clusters() dc.indexer_algorithm = 'inception' dc.included_index_entries_pk = [k.pk for k in IndexEntries.objects.all().filter(algorithm=dc.indexer_algorithm)] dc.components = 32 dc.save() clustering_task = TEvent() clustering_task.clustering = dc clustering_task.event_type = TEvent.CLUSTERING clustering_task.operation = 'perform_clustering' clustering_task.save() perform_clustering(clustering_task.pk) query,dv = create_query(10,False,['inception',],[],'data:image/png;base64,'+base64.encodestring(file('tests/query.png').read())) inception_query_by_image(query.pk) query,dv = create_query(10,True,['inception',],[],'data:image/png;base64,'+base64.encodestring(file('tests/query.png').read())) inception_query_by_image(query.pk) test_backup()
def ci(): """ Used in conjunction with travis for Continuous Integration testing :return: """ 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 dvaapp.views import handle_uploaded_file, handle_youtube_video from dvaapp.models import Video, Clusters, IndexEntries from django.conf import settings from dvaapp.tasks import extract_frames, perform_face_indexing, inception_index_by_id, perform_ssd_detection_by_id,\ perform_yolo_detection_by_id, inception_index_ssd_detection_by_id, export_video_by_id, import_video_by_id,\ perform_clustering 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) 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) handle_youtube_video('tomorrow never dies', 'https://www.youtube.com/watch?v=gYtz5sw98Bc') for i, v in enumerate(Video.objects.all()): extract_frames(v.pk) inception_index_by_id(v.pk) if i == 0: # save travis time by just running detection on first video perform_ssd_detection_by_id(v.pk) perform_yolo_detection_by_id(v.pk) perform_face_indexing(v.pk) inception_index_ssd_detection_by_id(v.pk) fname = export_video_by_id(v.pk) f = SimpleUploadedFile(fname, file("{}/exports/{}".format( settings.MEDIA_ROOT, fname)).read(), content_type="application/zip") vimported = handle_uploaded_file(f, fname) import_video_by_id(vimported.pk) dc = Clusters() dc.indexer_algorithm = 'inception' dc.included_index_entries_pk = [ k.pk for k in IndexEntries.objects.all().filter( algorithm=dc.indexer_algorithm) ] dc.components = 32 dc.save() perform_clustering(dc.pk) test_backup()
def cluster(): from lopq.utils import load_xvecs import django sys.path.append(os.path.dirname(__file__)) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dva.settings") django.setup() from dvaapp.tasks import perform_clustering from dvaapp.models import Video,Clusters,IndexEntries c = Clusters() c.indexer_algorithm = 'facenet' c.included_index_entries_pk = [k.pk for k in IndexEntries.objects.all() if k.algorithm == c.indexer_algorithm] c.components = 128 c.cluster_count = 32 c.save() perform_clustering(c.pk,True)
def cluster(): from lopq.utils import load_xvecs import django sys.path.append(os.path.dirname(__file__)) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dva.settings") django.setup() from dvaapp.tasks import perform_clustering from dvaapp.models import Video, Clusters, IndexEntries c = Clusters() c.video = Video.objects.get(pk=3) c.index_entries = IndexEntries.objects.get(video=c.video, algorithm='facenet') c.components = 128 c.cluster_count = 32 c.save() perform_clustering(c.pk)
def ci(): """ Used in conjunction with travis for Continuous Integration testing :return: """ 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 dvaapp.views import handle_uploaded_file, handle_youtube_video, pull_vdn_list\ ,import_vdn_dataset_url from dvaapp.models import Video, Clusters,IndexEntries,TEvent,VDNServer from django.conf import settings from dvaapp.operations.query_processing import QueryProcessing from dvaapp.tasks import extract_frames, inception_index_by_id, perform_ssd_detection_by_id,\ perform_yolo_detection_by_id, inception_index_regions_by_id, export_video_by_id, import_video_by_id,\ execute_index_subquery, perform_clustering, assign_open_images_text_tags_by_id, perform_face_detection,\ perform_face_indexing 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) 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) # handle_youtube_video('world is not enough', 'https://www.youtube.com/watch?v=P-oNz3Nf50Q') # Temporarily disabled due error in travis for i,v in enumerate(Video.objects.all()): extract_frames(TEvent.objects.create(video=v).pk) inception_index_by_id(TEvent.objects.create(video=v).pk) if i ==0: # save travis time by just running detection on first video perform_ssd_detection_by_id(TEvent.objects.create(video=v).pk) perform_face_detection(TEvent.objects.create(video=v).pk) inception_index_regions_by_id(TEvent.objects.create(video=v).pk) assign_open_images_text_tags_by_id(TEvent.objects.create(video=v).pk) fname = export_video_by_id(TEvent.objects.create(video=v,event_type=TEvent.EXPORT).pk) f = SimpleUploadedFile(fname, file("{}/exports/{}".format(settings.MEDIA_ROOT,fname)).read(), content_type="application/zip") vimported = handle_uploaded_file(f, fname) import_video_by_id(TEvent.objects.create(video=vimported).pk) dc = Clusters() dc.indexer_algorithm = 'inception' dc.included_index_entries_pk = [k.pk for k in IndexEntries.objects.all().filter(algorithm=dc.indexer_algorithm)] dc.components = 32 dc.save() clustering_task = TEvent() clustering_task.clustering = dc clustering_task.event_type = TEvent.CLUSTERING clustering_task.operation = 'perform_clustering' clustering_task.save() perform_clustering(clustering_task.pk) query_dict = { 'image_data_b64':base64.encodestring(file('tests/query.png').read()), 'indexers':[ { 'algorithm':'inception', 'count':10, 'approximate':False } ] } qp = QueryProcessing() qp.create_from_json(query_dict) execute_index_subquery(qp.indexer_queries[0].pk) query_dict = { 'image_data_b64':base64.encodestring(file('tests/query.png').read()), 'indexers':[ { 'algorithm':'inception', 'count':10, 'approximate':True } ] } qp = QueryProcessing() qp.create_from_json(query_dict) execute_index_subquery(qp.indexer_queries[0].pk) 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) test_backup()
def ci(): """ Used in conjunction with travis for Continuous Integration testing :return: """ 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 dvaapp.views import handle_uploaded_file, handle_youtube_video, pull_vdn_list\ ,import_vdn_dataset_url from dvaapp.models import Video, Clusters,IndexEntries,TEvent,VDNServer, DVAPQL from django.conf import settings from dvaapp.operations.processing import DVAPQLProcess from dvaapp.tasks import extract_frames, perform_indexing, export_video, import_video_by_id,\ perform_clustering, perform_analysis, perform_detection,\ segment_video, crop_regions_by_id 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) # handle_youtube_video('world is not enough', 'https://www.youtube.com/watch?v=P-oNz3Nf50Q') # Temporarily disabled due error in travis for i,v in enumerate(Video.objects.all()): if v.dataset: arguments = {'sync':True} extract_frames(TEvent.objects.create(video=v,arguments=arguments).pk) else: arguments = {'sync':True} segment_video(TEvent.objects.create(video=v,arguments=arguments).pk) arguments = {'index': 'inception'} 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},} crop_regions_by_id(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},} crop_regions_by_id(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) fname = export_video(TEvent.objects.create(video=v).pk) f = SimpleUploadedFile(fname, file("{}/exports/{}".format(settings.MEDIA_ROOT,fname)).read(), content_type="application/zip") vimported = handle_uploaded_file(f, fname) import_video_by_id(TEvent.objects.create(video=vimported).pk) dc = Clusters() dc.indexer_algorithm = 'inception' dc.included_index_entries_pk = [k.pk for k in IndexEntries.objects.all().filter(algorithm=dc.indexer_algorithm)] dc.components = 32 dc.save() clustering_task = TEvent() clustering_task.arguments = {'clusters_id':dc.pk} clustering_task.operation = 'perform_clustering' clustering_task.save() perform_clustering(clustering_task.pk) query_dict = { 'process_type': DVAPQL.QUERY, 'image_data_b64':base64.encodestring(file('tests/query.png').read()), 'indexer_queries':[ { 'algorithm':'inception', 'count':10, 'approximate':False } ] } qp = DVAPQLProcess() qp.create_from_json(query_dict) # execute_index_subquery(qp.indexer_queries[0].pk) query_dict = { 'process_type': DVAPQL.QUERY, 'image_data_b64':base64.encodestring(file('tests/query.png').read()), 'indexer_queries':[ { 'algorithm':'inception', 'count':10, 'approximate':True } ] } qp = DVAPQLProcess() qp.create_from_json(query_dict) # execute_index_subquery(qp.indexer_queries[0].pk) 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) test_backup()
def ci(): """ Used in conjunction with travis for Continuous Integration testing :return: """ 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 dvaapp.views import handle_uploaded_file, handle_youtube_video, pull_vdn_list\ ,import_vdn_dataset_url from dvaapp.models import Video, Clusters,IndexEntries,TEvent,VDNServer from django.conf import settings from dvaapp.operations.query_processing import QueryProcessing from dvaapp.tasks import extract_frames, perform_indexing, export_video_by_id, import_video_by_id,\ perform_clustering, perform_analysis, perform_detection,\ segment_video, crop_regions_by_id 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) # handle_youtube_video('world is not enough', 'https://www.youtube.com/watch?v=P-oNz3Nf50Q') # Temporarily disabled due error in travis for i,v in enumerate(Video.objects.all()): if v.dataset: arguments_json = json.dumps({'sync':True}) extract_frames(TEvent.objects.create(video=v,arguments_json=arguments_json).pk) else: arguments_json = json.dumps({'sync':True}) segment_video(TEvent.objects.create(video=v,arguments_json=arguments_json).pk) arguments_json = json.dumps({'index': 'inception'}) perform_indexing(TEvent.objects.create(video=v,arguments_json=arguments_json).pk) if i ==0: # save travis time by just running detection on first video # face_mtcnn arguments_json = json.dumps({'detector': 'face'}) dt = TEvent.objects.create(video=v,arguments_json=arguments_json) perform_detection(dt.pk) arguments_json = json.dumps({'filters':{'event_id':dt.pk},}) crop_regions_by_id(TEvent.objects.create(video=v,arguments_json=arguments_json).pk) # coco_mobilenet arguments_json = json.dumps({'detector': 'coco'}) dt = TEvent.objects.create(video=v, arguments_json=arguments_json) perform_detection(dt.pk) arguments_json = json.dumps({'filters':{'event_id':dt.pk},}) crop_regions_by_id(TEvent.objects.create(video=v,arguments_json=arguments_json).pk) # inception on crops from detector arguments_json = json.dumps({'index':'inception','target': 'regions','filters': {'event_id': dt.pk, 'w__gte': 50, 'h__gte': 50}}) perform_indexing(TEvent.objects.create(video=v,arguments_json=arguments_json).pk) # assign_open_images_text_tags_by_id(TEvent.objects.create(video=v).pk) fname = export_video_by_id(TEvent.objects.create(video=v,event_type=TEvent.EXPORT).pk) f = SimpleUploadedFile(fname, file("{}/exports/{}".format(settings.MEDIA_ROOT,fname)).read(), content_type="application/zip") vimported = handle_uploaded_file(f, fname) import_video_by_id(TEvent.objects.create(video=vimported).pk) dc = Clusters() dc.indexer_algorithm = 'inception' dc.included_index_entries_pk = [k.pk for k in IndexEntries.objects.all().filter(algorithm=dc.indexer_algorithm)] dc.components = 32 dc.save() clustering_task = TEvent() clustering_task.clustering = dc clustering_task.event_type = TEvent.CLUSTERING clustering_task.operation = 'perform_clustering' clustering_task.save() perform_clustering(clustering_task.pk) query_dict = { 'image_data_b64':base64.encodestring(file('tests/query.png').read()), 'indexers':[ { 'algorithm':'inception', 'count':10, 'approximate':False } ] } qp = QueryProcessing() qp.create_from_json(query_dict) # execute_index_subquery(qp.indexer_queries[0].pk) query_dict = { 'image_data_b64':base64.encodestring(file('tests/query.png').read()), 'indexers':[ { 'algorithm':'inception', 'count':10, 'approximate':True } ] } qp = QueryProcessing() qp.create_from_json(query_dict) # execute_index_subquery(qp.indexer_queries[0].pk) 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) test_backup()