Exemple #1
0
def retrieve_video_frame_image():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.args.to_dict(flat=True)
    video_uuid = data.get('video_uuid')
    frame_number = int(data.get('frame_number'))
    image_data, content_type = storage.retrieve_video_frame_image(team_uuid, video_uuid, frame_number)
    return Response(image_data, mimetype=content_type)
Exemple #2
0
def set_user_preference():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    key = data.get('key')
    value = data.get('value')
    storage.store_user_preference(team_uuid, key, value)
    return 'OK'
Exemple #3
0
def retrieve_training_summaries():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    model_uuid = data.get('model_uuid')
    retrieve_scalars = (data.get('retrieve_scalars') == 'true')
    retrieve_images = (data.get('retrieve_images') == 'true')
    model_entity = model_trainer.retrieve_model_entity(team_uuid, model_uuid)
    training_updated, training_sorted_tags, training_sorted_steps, training_summaries = model_trainer.retrieve_training_summaries(
        team_uuid, model_uuid, retrieve_scalars, retrieve_images)
    eval_updated, eval_sorted_tags, eval_sorted_steps, eval_summaries = model_trainer.retrieve_eval_summaries(
        team_uuid, model_uuid, retrieve_scalars, retrieve_images)
    sanitize(model_entity)
    response = {
        'model_entity': model_entity,
        'training_updated': training_updated,
        'training_sorted_tags': training_sorted_tags,
        'training_sorted_steps': training_sorted_steps,
        'training_summaries': training_summaries,
        'eval_updated': eval_updated,
        'eval_sorted_tags': eval_sorted_tags,
        'eval_sorted_steps': eval_sorted_steps,
        'eval_summaries': eval_summaries,
    }
    blob_storage.set_cors_policy_for_get()
    return flask.jsonify(response)
Exemple #4
0
def retrieve_dataset_entities():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    dataset_entities = storage.retrieve_dataset_list(team_uuid)
    sanitize(dataset_entities)
    response = {
        'dataset_entities': dataset_entities,
    }
    return flask.jsonify(response)
Exemple #5
0
def store_video_frame_include_in_dataset():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    video_uuid = data.get('video_uuid')
    frame_number = int(data.get('frame_number'))
    include_frame_in_dataset = (data.get('include_frame_in_dataset') == 'true')
    storage.store_video_frame_include_in_dataset(team_uuid, video_uuid, frame_number, include_frame_in_dataset)
    return 'ok'
Exemple #6
0
def store_video_frame_bboxes_text():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    video_uuid = data.get('video_uuid')
    frame_number = int(data.get('frame_number'))
    bboxes_text = data.get('bboxes_text')
    storage.store_video_frame_bboxes_text(team_uuid, video_uuid, frame_number, bboxes_text)
    return 'ok'
Exemple #7
0
def delete_dataset_zip():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    dataset_zip_uuid = data.get('dataset_zip_uuid')
    partition_index = int(data.get('partition_index'))
    blob_storage.delete_dataset_zip(team_uuid, dataset_zip_uuid, partition_index)
    storage.delete_dataset_zipper(team_uuid, dataset_zip_uuid, partition_index)
    return 'OK'
Exemple #8
0
def retrieve_video_entities():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    video_entities = storage.retrieve_video_list(team_uuid)
    sanitize(video_entities)
    response = {
        'video_entities': video_entities,
    }
    return flask.jsonify(response)
Exemple #9
0
def retrieve_video_entity():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    video_uuid = data.get('video_uuid')
    video_entity = storage.retrieve_video_entity(team_uuid, video_uuid)
    sanitize(video_entity)
    response = {
        'video_entity': video_entity,
    }
    return flask.jsonify(response)
Exemple #10
0
def cancel_training_model():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    model_uuid = data.get('model_uuid')
    model_entity = model_trainer.cancel_training_model(team_uuid, model_uuid)
    sanitize(model_entity)
    response = {
        'model_entity': model_entity,
    }
    return flask.jsonify(response)
Exemple #11
0
def can_delete_models():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    model_uuids_json = data.get('model_uuids')
    can_delete_models, messages = storage.can_delete_models(team_uuid, model_uuids_json)
    response = {
        'can_delete_models': can_delete_models,
        'messages': messages,
    }
    return flask.jsonify(response)
Exemple #12
0
def create_tflite():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    model_uuid = data.get('model_uuid')
    download_url = tflite_creator.create_tflite(team_uuid, model_uuid)
    response = {
        'download_url': download_url,
    }
    blob_storage.set_cors_policy_for_get()
    return flask.jsonify(response)
Exemple #13
0
def retrieve_model_entities():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    model_entities = model_trainer.retrieve_model_list(team_uuid)
    team_entity = storage.retrieve_team_entity(team_uuid)
    sanitize(model_entities)
    response = {
        'total_training_minutes': team_info.TOTAL_TRAINING_MINUTES_PER_TEAM,
        'remaining_training_minutes': team_entity['remaining_training_minutes'],
        'model_entities': model_entities,
    }
    return flask.jsonify(response)
Exemple #14
0
def label_video():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    video_uuid = flask.request.args.get('video_uuid')
    video_entity = storage.retrieve_video_entity_for_labeling(team_uuid, video_uuid)
    video_frame_entity_0 = storage.retrieve_video_frame_entities_with_image_urls(
        team_uuid, video_uuid, 0, 0)[0]
    sanitize(video_entity)
    sanitize(video_frame_entity_0)
    return flask.render_template('labelVideo.html', time_time=time.time(), project_id=constants.PROJECT_ID,
        team_preferences=storage.retrieve_user_preferences(team_uuid),
        video_uuid=video_uuid, video_entity=video_entity, video_frame_entity_0=video_frame_entity_0)
Exemple #15
0
def index():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    program, team_number = team_info.retrieve_program_and_team_number(
        flask.session)
    return flask.render_template(
        'root.html',
        time_time=time.time(),
        project_id=constants.PROJECT_ID,
        program=program,
        team_number=team_number,
        team_preferences=storage.retrieve_user_preferences(team_uuid),
        starting_models=model_trainer.get_starting_model_names())
Exemple #16
0
def retrieve_model_entity():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    model_uuid = data.get('model_uuid')
    model_entity = model_trainer.retrieve_model_entity(team_uuid, model_uuid)
    team_entity = storage.retrieve_team_entity(team_uuid)
    sanitize(model_entity)
    response = {
        'remaining_training_minutes': team_entity['remaining_training_minutes'],
        'model_entity': model_entity,
    }
    return flask.jsonify(response)
Exemple #17
0
def monitor_training():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    model_uuid = flask.request.args.get('model_uuid')
    model_entities_by_uuid, dataset_entities_by_uuid, video_entities_by_uuid = storage.retrieve_entities_for_monitor_training(
        team_uuid, model_uuid, model_trainer.retrieve_model_list(team_uuid))
    sanitize(model_entities_by_uuid)
    sanitize(dataset_entities_by_uuid)
    sanitize(video_entities_by_uuid)
    return flask.render_template('monitorTraining.html', time_time=time.time(), project_id=constants.PROJECT_ID,
        team_preferences=storage.retrieve_user_preferences(team_uuid),
        model_uuid=model_uuid,
        model_entities_by_uuid=model_entities_by_uuid,
        dataset_entities_by_uuid=dataset_entities_by_uuid,
        video_entities_by_uuid=video_entities_by_uuid)
Exemple #18
0
def retrieve_video_frame_entities_with_image_urls():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    video_uuid = data.get('video_uuid')
    min_frame_number = int(data.get('min_frame_number'))
    max_frame_number = int(data.get('max_frame_number'))
    video_frame_entities = storage.retrieve_video_frame_entities_with_image_urls(
        team_uuid, video_uuid, min_frame_number, max_frame_number)
    sanitize(video_frame_entities)
    response = {
        'video_frame_entities': video_frame_entities,
    }
    blob_storage.set_cors_policy_for_get()
    return flask.jsonify(response)
Exemple #19
0
def prepare_to_zip_dataset():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    dataset_uuid = data.get('dataset_uuid')
    dataset_zip_uuid, partition_count = dataset_zipper.prepare_to_zip_dataset(
        team_uuid, dataset_uuid)
    action_parameters = dataset_zipper.make_action_parameters(
        team_uuid, dataset_uuid, dataset_zip_uuid, partition_count)
    action.trigger_action_via_blob(action_parameters)
    response = {
        'dataset_zip_uuid': dataset_zip_uuid,
        'partition_count': partition_count,
    }
    return flask.jsonify(response)
Exemple #20
0
def prepare_to_start_tracking():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    video_uuid = data.get('video_uuid')
    init_frame_number = int(data.get('init_frame_number'))
    init_bboxes_text = data.get('init_bboxes_text')
    tracker_name = data.get('tracker_name')
    scale = float(data.get('scale'))
    tracker_uuid = tracking.prepare_to_start_tracking(team_uuid, video_uuid,
        tracker_name, scale, init_frame_number, init_bboxes_text)
    response = {
        'tracker_uuid': tracker_uuid,
    }
    return flask.jsonify(response)
Exemple #21
0
def prepare_to_start_dataset_production():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    description = data.get('description')
    video_uuids_json = data.get('video_uuids')
    eval_percent = int(data.get('eval_percent'))
    create_time_ms = int(data.get('create_time_ms'))
    dataset_uuid = dataset_producer.prepare_to_start_dataset_production(
        team_uuid, description, video_uuids_json, eval_percent, create_time_ms)
    action_parameters = dataset_producer.make_action_parameters(
        team_uuid, dataset_uuid, video_uuids_json, eval_percent, create_time_ms)
    action.trigger_action_via_blob(action_parameters)
    response = {
        'dataset_uuid': dataset_uuid,
    }
    return flask.jsonify(response)
Exemple #22
0
def retrieve_dataset_entity():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    dataset_uuid = data.get('dataset_uuid')
    dataset_entity = storage.retrieve_dataset_entity(team_uuid, dataset_uuid)
    if dataset_entity['dataset_completed']:
        frames_written = None
    else:
        frames_written = storage.retrieve_dataset_record_writer_frames_written(dataset_entity)
    sanitize(dataset_entity)
    response = {
        'dataset_entity': dataset_entity,
    }
    if frames_written is not None:
        response['frames_written'] = frames_written
    return flask.jsonify(response)
Exemple #23
0
def prepare_to_upload_video():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    description = data.get('description')
    video_filename = data.get('video_filename')
    file_size = int(data.get('file_size'))
    content_type = data.get('content_type')
    create_time_ms = int(data.get('create_time_ms'))
    video_uuid, upload_url = storage.prepare_to_upload_video(
        team_uuid, description, video_filename, file_size, content_type, create_time_ms)
    frame_extractor.start_frame_extraction(team_uuid, video_uuid)
    response = {
        'video_uuid': video_uuid,
        'upload_url': upload_url,
    }
    blob_storage.set_cors_policy_for_put()
    return flask.jsonify(response)
Exemple #24
0
def get_dataset_zip_status():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    dataset_zip_uuid = data.get('dataset_zip_uuid')
    partition_count = int(data.get('partition_count'))
    exists_array, download_url_array = blob_storage.get_dataset_zip_download_url(
        team_uuid, dataset_zip_uuid, partition_count)
    file_count_array, files_written_array = storage.retrieve_dataset_zipper_files_written(
        team_uuid, dataset_zip_uuid, partition_count)
    response = {
        'is_ready_array': exists_array,
        'download_url_array': download_url_array,
        'file_count_array': file_count_array,
        'files_written_array': files_written_array,
    }
    blob_storage.set_cors_policy_for_get()
    return flask.jsonify(response)
Exemple #25
0
def start_training_model():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    description = data.get('description')
    dataset_uuids_json = data.get('dataset_uuids')
    starting_model = data.get('starting_model')
    max_running_minutes = int(data.get('max_running_minutes'))
    num_training_steps = int(data.get('num_training_steps'))
    create_time_ms = int(data.get('create_time_ms'))
    model_entity = model_trainer.start_training_model(team_uuid, description, dataset_uuids_json,
        starting_model, max_running_minutes, num_training_steps, create_time_ms)
    action_parameters = model_trainer.make_action_parameters(team_uuid, model_entity['model_uuid'])
    action.trigger_action_via_blob(action_parameters)
    team_entity = storage.retrieve_team_entity(team_uuid)
    sanitize(model_entity)
    response = {
        'remaining_training_minutes': team_entity['remaining_training_minutes'],
        'model_entity': model_entity,
    }
    return flask.jsonify(response)
Exemple #26
0
def continue_tracking():
    time_limit = datetime.now() + timedelta(seconds=25)
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    video_uuid = data.get('video_uuid')
    tracker_uuid = data.get('tracker_uuid')
    frame_number = int(data.get('frame_number'))
    bboxes_text = data.get('bboxes_text')
    storage.continue_tracking(team_uuid, video_uuid, tracker_uuid, frame_number, bboxes_text)
    if 'retrieve_frame_number' in data:
        time.sleep(0.2)
        retrieve_frame_number = int(data.get('retrieve_frame_number'))
        tracker_failed, frame_number, bboxes_text = storage.retrieve_tracked_bboxes(
            video_uuid, tracker_uuid, retrieve_frame_number, time_limit)
        response = {
            'tracker_failed': tracker_failed,
            'frame_number': frame_number,
            'bboxes_text': bboxes_text,
        }
        return flask.jsonify(response)
    return 'OK'
Exemple #27
0
def create_tflite_graph_pb():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    model_uuid = data.get('model_uuid')
    tflite_creator.create_tflite_graph_pb(team_uuid, model_uuid)
    return 'OK'
Exemple #28
0
def delete_model():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    model_uuid = data.get('model_uuid')
    storage.delete_model(team_uuid, model_uuid)
    return 'OK'
Exemple #29
0
def start_frame_extraction():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    video_uuid = data.get('video_uuid')
    frame_extractor.start_frame_extraction(team_uuid, video_uuid)
    return 'OK'
Exemple #30
0
def delete_video():
    team_uuid = team_info.retrieve_team_uuid(flask.session, flask.request)
    data = flask.request.form.to_dict(flat=True)
    video_uuid = data.get('video_uuid')
    storage.delete_video(team_uuid, video_uuid)
    return 'OK'