def read_model(model_filename):

    model = detector_model_pb2.DetectorModel()
    f = open(model_filename, "rb")
    model.ParseFromString(f.read())
    f.close()

    if not model.IsInitialized():
        print("Input file seems not to be a DetectorModel, " \
              "trying as MultiScalesDetectorModel")

        model = detector_model_pb2.MultiScalesDetectorModel()
        f = open(model_filename, "rb")
        model.ParseFromString(f.read())
        f.close()

    if not model.IsInitialized():
        print("Input file seems not to be "\
              "a DetectorModel nor a  MultiScalesDetectorModel")
        raise Exception("Unknown input file format")

    print(model.detector_name)
    if model.training_dataset_name:
        print("trained on dataset:", model.training_dataset_name)

    if type(model) is detector_model_pb2.DetectorModel \
       and model.soft_cascade_model:
        #print("Model shrinking factor ==",
        #      model.soft_cascade_model.shrinking_factor)
        print("Model channels description ==",
              model.soft_cascade_model.channels_description)

    return model
Exemplo n.º 2
0
def read_model(model_filename):

    model = detector_model_pb2.DetectorModel()
    f = open(model_filename, "rb")
    model.ParseFromString(f.read())
    f.close()

    return model
Exemplo n.º 3
0
def read_model_old(model_filepath):
    model = detector_model_pb2.DetectorModel()
    f = open(model_filepath, "rb")
    model.ParseFromString(f.read())
    f.close()
    assert model.IsInitialized()

    return model
Exemplo n.º 4
0
def read_model(model_filename):
        
    model = detector_model_pb2.DetectorModel()
    f = open(model_filename, "rb")
    model.ParseFromString(f.read())
    f.close()
    
    if not model.IsInitialized():
        print("Input file seems not to be a DetectorModel, " \
              "trying as MultiScalesDetectorModel")

        model = detector_model_pb2.MultiScalesDetectorModel()
        f = open(model_filename, "rb")
        model.ParseFromString(f.read())
        f.close()

    if not model.IsInitialized():
        print("Input file seems not to be "\
              "a DetectorModel nor a  MultiScalesDetectorModel")
        raise Exception("Unknown input file format")

    return model