Beispiel #1
0
def init_app_runtime():
    init_runtime(logging_level=constants.LOGGING_LEVEL)
    logger.info(ENV.to_json() if ENV.IS_DEV_ENV else ENV.to_str())
Beispiel #2
0
#  Copyright (c) 2020 the original author or authors
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#       https://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
#  or implied. See the License for the specific language governing
#  permissions and limitations under the License.

import logging

from src.init_runtime import init_runtime

init_runtime(logging.DEBUG)
Beispiel #3
0
def get_plausible_thresholds_iterator(arg_count):
    one_arg_values = [
        0.01, 0.1, 0.2, 0.3, 0.4, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85,
        0.9, 0.95, 0.99
    ]
    all_arg_values = list(itertools.product(one_arg_values, repeat=arg_count))
    random.shuffle(all_arg_values)
    return all_arg_values


def random_thresholds_generator(arg_count):
    while True:
        yield [random.uniform(0, 1) for _ in range(arg_count)]


if __name__ == '__main__':
    init_runtime(logging_level=LOGGING_LEVEL)
    logger.info(ENV.to_json() if ENV_MAIN.IS_DEV_ENV else ENV.to_str())

    task = Facenet2018DetectionThresholdOptimization()
    threshold_iterators = [
        get_plausible_thresholds_iterator(task.arg_count),
        random_thresholds_generator(task.arg_count)
    ]

    storage = ResultsStorage()
    optimizer = Optimizer(task, storage, checkpoint_every_s=120)
    for threshold_iterator in threshold_iterators:
        optimizer.optimize(threshold_iterator)