def temp_import_detector(path="/Users/aub3/tempd"): """ Test importing detectors """ setup_django() import json from django.conf import settings from dvaapp.models import DeepModel d = DeepModel() with open("{}/input.json".format(path)) as infile: data = json.load(infile) d.name = "test detector" d.class_names = json.dumps(data['class_names']) d.phase_1_log = file("{}/phase_1.log".format(path)).read d.phase_2_log = file("{}/phase_2.log".format(path)).read d.frames_count = 500 d.boxes_count = 500 d.detector_type = d.YOLO d.model_type = DeepModel.DETECTOR d.class_distribution = json.dumps(data['class_names']) d.save() d.create_directory() shutil.copy( "{}/phase_2_best.h5".format(path), "{}/detectors/{}/phase_2_best.h5".format(settings.MEDIA_ROOT, d.pk))
def import_vdn_detector_url(server, url, user, cached_response): response = None try: r = requests.get(url) response = r.json() except: pass if not response: response = cached_response detector = DeepModel() detector.model_type = DeepModel.DETECTOR detector.name = response['name'] detector.detector_type = response.get('detector_type', DeepModel.YOLO) detector.save() if response.get('download_url', False): p = processing.DVAPQLProcess() query = { 'process_type': DVAPQL.PROCESS, 'tasks': [{ 'arguments': { 'detector_pk': detector.pk, 'download_url': response['download_url'] }, 'operation': 'perform_detector_import', }] } p.create_from_json(j=query, user=user) p.launch() elif response.get('aws_key', False) and response.get('aws_bucket', False): raise NotImplementedError else: raise NotImplementedError