예제 #1
0
            NUM_CLASSES = 1
        else:
            NUM_CLASSES = 90

        def __init__(self):
            super(TestConfig, self).__init__(type)

    return TestConfig()


# Read sequentail Models or Gather all Models from models/
config = Config('od')
if config.SEQ_MODELS:
    model_names = config.SEQ_MODELS
else:
    model_names = get_model_list(MODELS_DIR)

# Sequential testing
for model_name in model_names:
    print("> testing model: {}".format(model_name))
    # conditionals
    optimized = False
    single_class = False
    # Test Model
    if 'hands' in model_name or 'person' in model_name:
        single_class = True
    if 'deeplab' in model_name:
        config = create_test_config('dl', model_name, optimized, single_class)
        model = DeepLabModel(config).prepare_model(INPUT_TYPE)
    else:
        config = create_test_config('od', model_name, optimized, single_class)
예제 #2
0
    if optimized:
        model_path=ROOT_DIR+'/models/{}/optimized_inference_graph.pb'.format(model)
        log_dir=ROOT_DIR+'/models/{}/log_opt/'.format(model)
    else:
        model_path=ROOT_DIR+'/models/{}/frozen_inference_graph.pb'.format(model)
        log_dir=ROOT_DIR+'/models/{}/log/'.format(model)

    with session.Session(graph=ops.Graph()) as sess:
        with gfile.FastGFile(model_path, "rb") as f:
          graph_def = graph_pb2.GraphDef()
          graph_def.ParseFromString(f.read())
          importer.import_graph_def(graph_def)
        pb_visual_writer = summary.FileWriter(log_dir)
        pb_visual_writer.add_graph(sess.graph)
    print("> Model {} Imported. \nVisualize by running: \
    tensorboard --logdir={}".format(model_path, log_dir))

# Gather all Model Names in models/
MODELS_DIR = os.path.join(ROOT_DIR,'models')
models = get_model_list(MODELS_DIR)

# Create Tensorboard readable tfevent files in models/{}/log
for model in models:
    optimized=False
    create_tfevent_from_pb(model,optimized)
    # Check if there is an optimized graph
    model_dir =  os.path.join(MODELS_DIR,model)
    optimized = check_if_optimized_model(model_dir)
    if optimized:
        create_tfevent_from_pb(model,optimized)