def test_namespace(self): Config.clear() Config.define_int("namespace1.test_int", 5, "A test for int") with Config.namespace("namespace2"): Config.define_int("test_int", 5, "A test for int") Config.define_int("subnamespace.test_int", 5, "A test for int") with Config.namespace("subnamespace2"): Config.define_int("plop", 4, "test of subnamespace") self.assertDictEqual( Config.get_dict(), { 'namespace1': { 'test_int': 5 }, 'namespace2': { 'test_int': 5, 'subnamespace': { 'test_int': 5 }, 'subnamespace2': { 'plop': 4 } } })
def test_load_conf_cmd(self, mock_args): Config.clear() Config.define_bool("VaR", False, "turn me true") Config.define_int("v1", 1, "var") Config.define_int("v2", 2, "var") Config.define_float_list("list", [5., 6, "7."], "A test for list") with Config.namespace("n1"): Config.define_int("v1", 1, "var") Config.define_int("v2", 2, "var") Config.define_bool("V3", True, "turn me false") Config.load_conf() self.assertEqual(Config.get_var("v1"), 2) self.assertEqual(Config.get_var("v2"), 3) self.assertEqual(Config.get_var("n1.v1"), 2) self.assertEqual(Config.get_var("n1.v2"), 3) self.assertEqual(Config.get_var("n1.v3"), False) self.assertEqual(Config.get_var("VAr"), True) self.assertEqual(Config.get_var("list"), [1.0, 2.0, 3.0])
# For now it only keeps "detection_classes" == 1, i.e. "class"="person" coloredlogs.install(level="DEBUG") Config.define_str( "model_path", "/opt/model/frozen_inference_graph.pb", "Path of the model to load and execute, for instance" "/opt/model/frozen_inference_graph.pb. If you're using docker-compose you shouldn't change this." ) Config.define_str("input_dir", "", "Path where the images to annotate are stored") Config.define_str( "output_dir", "", "Path to store pre-annotations (model annotations to help human annotators)" ) with Config.namespace("class"): Config.define_str_list("names", [], "name of the classes to annotate") with Config.namespace("object_detection"): Config.define_float("threshold", 0.2, "Discard boxes with score below this value") Config.define_float( "max_width", 1.0, "Discard boxes with width upper this value because in some cases, very large detections are mostly false positives" ) def main(): Config.load_conf() config = Config.get_dict() assert config["model_path"] != "", "model_path can't be empty" assert config["input_dir"] != "", "input_dir can't be empty"
from flask import Flask, url_for, redirect, Response, jsonify from flask_cors import CORS import flask from distribute_config import Config coloredlogs.install(level='DEBUG') Config.define_str("images_path", "static/images", "Path where are stored the images to annotate") Config.define_str("human_annotations_path", "static/human_annotations", "Path where are stored human annotation") Config.define_str("model_annotations_path", "static/model_annotations", "Path where are stored model annotation for helping human") with Config.namespace("class"): Config.define_str_list("names", [], "name of the classes to annotate") Config.define_str_list("colors", [], "colors for each classes") Config.define_int("min_height", 0, "Rectangle with lower height will be displayed red") Config.define_int("min_width", 0, "Rectangle with lower width will be displayed red") image_provider = None class ImageProvider: def __init__(self): """class providing path of images to process """ # user-provided attributes