Esempio n. 1
0
def train_get_loss(imagettes_train,
                   nbr_entrainement,
                   name_train,
                   nbr=5,
                   coef=1.3,
                   flip=True):

    imagettes_train_copy = imagettes_train.copy()
    images_2, labels_2, labels2_2 = common_2.read_imagettes(
        imagettes_train_copy, nbr=nbr, coef=coef, flip=flip)
    images_2 = np.array(images_2, dtype=np.float32) / 255
    labels_2 = np.array(labels_2, dtype=np.float32)
    train_ds_2 = tf.data.Dataset.from_tensor_slices(
        (images_2, labels_2)).batch(batch_size)
    Model = model.model(config.nbr_classes, config.nbr_boxes, config.cellule_y,
                        config.cellule_x)

    chdir(path_model_saved)
    string = path_model_saved + name_train
    optimizer = tf.keras.optimizers.Adam(learning_rate=1E-4)
    #checkpoint=tf.train.Checkpoint(model=Model)
    train_loss = tf.keras.metrics.Mean()
    checkpoint = tf.train.Checkpoint(model=Model)
    checkpoint.restore(tf.train.latest_checkpoint(string))
    LOSS = common_2.train(train_ds_2, nbr_entrainement, string, labels2_2,
                          optimizer, Model, train_loss, checkpoint)
    checkpoint.save(file_prefix=string)

    return LOSS
Esempio n. 2
0
string = "/mnt/VegaSlowDataDisk/c3po_interface_mark/Materiels/Models/Yolo_models/training/"

optimizer = tf.keras.optimizers.Adam(learning_rate=1E-4)
checkpoint = tf.train.Checkpoint(model=Model)
train_loss = tf.keras.metrics.Mean()
checkpoint = tf.train.Checkpoint(model=model)
checkpoint.restore(tf.train.latest_checkpoint(string))

start = time.time()
end = time.time()
print((end - start) / 60)
checkpoint.save(file_prefix=string)
#common.train(train_ds, nbr_entrainement,string,labels2)

common.train(train_ds, nbr_entrainement, string, labels2_train, optimizer,
             model, train_loss, checkpoint)

optimizer = tf.keras.optimizers.Adam(learning_rate=1E-4)
checkpoint = tf.train.Checkpoint(model=model)
train_loss = tf.keras.metrics.Mean()

checkpoint = tf.train.Checkpoint(model=model)
checkpoint.restore(tf.train.latest_checkpoint(string))

#train(train_ds, 400)
#train_test_split(train_ds)
start = time.time()
train(train_ds, 600, string, labels2_train)
end = time.time()
print((end - start) / 60)
checkpoint.save(file_prefix=string)
Esempio n. 3
0
                                                        flip=True)
images_2 = np.array(images_2, dtype=np.float32) / 255
labels_2 = np.array(labels_2, dtype=np.float32)
train_ds_2 = tf.data.Dataset.from_tensor_slices(
    (images_2, labels_2)).batch(batch_size)

Model = model.model(config.nbr_classes, config.nbr_boxes, config.cellule_y,
                    config.cellule_x)

# note: plein de modèles entrainés qui sont mis dans différents sous-répertoires
# un sous-répertoire correspond à un modèle pour Yolo
string = path_model_saved + "generateur_avec_flip_1000/"

optimizer = tf.keras.optimizers.Adam(learning_rate=1E-4)
checkpoint = tf.train.Checkpoint(model=Model)
train_loss = tf.keras.metrics.Mean()

checkpoint = tf.train.Checkpoint(model=Model)
checkpoint.restore(tf.train.latest_checkpoint(string))

#train(train_ds, 400)
#train_test_split(train_ds)
start = time.time()
nbr_entrainement = 1
LOSS = common_2.train(train_ds_2, nbr_entrainement, string, labels2_2,
                      optimizer, Model, train_loss, checkpoint)
end = time.time()
print((end - start) / 60)
checkpoint.save(file_prefix=string)
#shutil.rmtree('training_bruit/')