Exemplo n.º 1
0
from utils.model import load_weights
from utils.training import Logger

os.environ["CUDA_VISIBLE_DEVICES"] = '2'

# In[3]
# TextBoxes++ + DenseNet
model = TBPP512_dense(softmax=False)

weights_path = None
freeze = []
batch_size = 6
experiment = 'dsodtbpp512fl_synthtext'

# In[4]
prior_util = PriorUtil(model)

if weights_path is not None:
    load_weights(model, weights_path)

for layer in model.layers:
    layer.trainable = not layer.name in freeze

#optim = keras.optimizers.SGD(lr=1e-3, momentum=0.9, decay=0, nesterov=True)
optim = keras.optimizers.Adam(lr=1e-3,
                              beta_1=0.9,
                              beta_2=0.999,
                              epsilon=0.001,
                              decay=0.0)

# weight decay
Exemplo n.º 2
0
    "threshold": 0.01
}
tfnet = TFNet(yolo9000)

# Starting the model here.1
Model = TBPP512_dense
input_shape = (512, 512, 3)
weights_path = 'weights.022.h5'
confidence_threshold = 0.35
confidence_threshold = 0.25
sl_graph = tf.Graph()
with sl_graph.as_default():
    sl_session = tf.Session()
    with sl_session.as_default():
        sl_model = Model(input_shape)
        prior_util = PriorUtil(sl_model)
        sl_model.load_weights(weights_path, by_name=True)
input_width = 256
input_height = 32
weights_path = 'weights.022.h5'


def get_iou(bb1, bb2):
    """
    Calculate the Intersection over Union (IoU) of two bounding boxes.

    Parameters
    ----------
    bb1 : dict
        Keys: {'x1', 'x2', 'y1', 'y2'}
        The (x1, y1) position is at the top left corner,
Exemplo n.º 3
0
    data_path = './data/ky_test'
    dataset_name = 'AGM_GOOD'

    confidence_threshold = 0.25
    image_names = np.sort(
        glob.glob(os.path.join(data_path, dataset_name, '*', '*.bmp')))
    print(len(image_names))
    annotation_path = os.path.join(data_path, dataset_name, 'Annotations')

    if not os.path.exists(annotation_path):
        os.makedirs(annotation_path)

    # TextBoxes++ + DenseNet
    tbpp = TBPP512_dense(softmax=False)
    # model = TBPP512(softmax=False)
    prior_util = PriorUtil(tbpp)
    checkdir = os.path.dirname(weights_path)

    input_width = 256
    input_height = 32
    crnn = CRNN((input_width, input_height, 1),
                len(alphabet),
                prediction_only=True,
                gru=False)

    print("started loading model weights")
    tic = time.time()
    tbpp.load_weights(weights_path)
    crnn.load_weights(weights_path_crnn)
    print(time.time() - tic)
    print("finished loading model weights")
Exemplo n.º 4
0
from crnn_utils import decode

if __name__ == '__main__':

    Model = TBPP512_dense
    input_shape = (512, 512, 3)
    weights_path = 'weights.022.h5'
    confidence_threshold = 0.35
    confidence_threshold = 0.25

    sl_graph = tf.Graph()
    with sl_graph.as_default():
        sl_session = tf.Session()
        with sl_session.as_default():
            sl_model = Model(input_shape)
            prior_util = PriorUtil(sl_model)
            sl_model.load_weights(weights_path, by_name=True)

    input_width = 256
    input_height = 32
    weights_path = 'weights.022.h5'

    crnn_graph = tf.Graph()
    with crnn_graph.as_default():
        crnn_session = tf.Session()
        with crnn_session.as_default():
            crnn_model = CRNN((input_width, input_height, 1),
                              len(alphabet),
                              prediction_only=True,
                              gru=True)
            crnn_model.load_weights(weights_path, by_name=True)
weights_path = options.weights_file
output_dir = options.output_dir
map_images_dir = options.images_dir
do_preprocess = bool(options.preprocess)
test_only = bool(options.test_only)
test_split_file = options.test_split
confidence_threshold = options.confidence
do_rotate_image = bool(options.rotate)

# TextBoxes++ + DenseNet
model = TBPP512_dense(softmax=False)

load_weights(model, weights_path)

prior_util = PriorUtil(model)

test_filenames = []
if test_only:
    with open(test_split_file) as f:
        test_filenames = [line.replace("\n", "") for line in f.readlines()]

crop_h = 512
crop_w = 512
step = 400

angles = range(-90, 95, 5) if do_rotate_image else [0]

for filepath in glob.glob(os.path.join(map_images_dir, 'D*')):
    filename = filepath.split('/')[-1]