Ejemplo n.º 1
0
if __name__ == '__main__':

    # dataset = 'dataset-sample'  #  0.5 GB download
    dataset = 'dataset-medium' # 9.0 GB download

    config = {
        'name' : 'baseline-focal-fastai',
        'dataset' : dataset,
    }

    wandb.init(config=config)

    datasets.download_dataset(dataset)

    # train the baseline model and save it in models folder
    custom_training.train_model(dataset)

    # use the train model to run inference on all test scenes
    inference.run_inference(dataset)

    # scores all the test images compared to the ground truth labels then
    # send the scores (f1, precision, recall) and prediction images to wandb
    score, predictions = scoring.score_predictions(dataset)
    print(score)
    wandb.log(score)

    for f1, f2 in predictions:
        wandb.save( f1 )
        wandb.save( f2 )
Ejemplo n.º 2
0
from libs import inference_keras
from libs import scoring

import wandb

if __name__ == '__main__':
    dataset = 'dataset-sample'  #  0.5 GB download
    #dataset = 'dataset-medium' # 9.0 GB download

    config = {
        'name' : 'baseline-keras',
        'dataset' : dataset,
    }

    wandb.init(config=config)

    datasets.download_dataset(dataset)

    # train the model
    model = models_keras.build_unet(encoder='resnet18')
    training_keras.train_model(dataset, model)

    # use the train model to run inference on all test scenes
    inference_keras.run_inference(dataset, model=model, basedir=wandb.run.dir)

    # scores all the test images compared to the ground truth labels then
    # send the scores (f1, precision, recall) and prediction images to wandb
    score, _ = scoring.score_predictions(dataset, basedir=wandb.run.dir)
    print(score)
    wandb.log(score)
                              custom_objects={'tf': tf},
                              compile=False)
model_vgg.summary()

dataset = 'dataset-medium'
config = {
    'name': 'baseline-keras',
    'dataset': dataset,
}

#wandb.init(config=config)

inference_keras.run_inference(dataset,
                              model=model_res,
                              basedir='predictions_resnet18')
score, _ = scoring.score_predictions(dataset, basedir='predictions_resnet18')
print(score)
inference_keras.run_inference(dataset,
                              model=model_vgg,
                              basedir='predictions_vgg16')
score, _ = scoring.score_predictions(dataset, basedir='predictions_vgg16')
print(score)

acc_res = []
acc_gmm = []
acc_vgg = []
acc = []
for predict in predict_ids:  #or some list
    img_res = f'./predictions_resnet18/{predict}-prediction.png'
    img_vgg = f'./predictions_vgg16/{predict}-prediction.png'
    img_gmm = Main.runcluster(dataset, predict, basedir='predictions_cluster')