def test_2DSegmentation(): os.makedirs(os.getcwd() + "/tests/segmentation/testimages/train/image/", exist_ok=True) os.makedirs(os.getcwd() + "/tests/segmentation/testimages/train/groundtruth/", exist_ok=True) os.makedirs(os.getcwd() + "/tests/segmentation/testimages/test/image/", exist_ok=True) os.makedirs(os.getcwd() + "/tests/segmentation/testimages/test/groundtruth/", exist_ok=True) X_true = np.ones((32, 32, 3)) Y_true = 255. * np.ones((32, 32, 3)) for i in range(0,20): imsave(os.getcwd() + "/tests/segmentation/testimages/train/image/image"+str(i)+".jpg", X_true) imsave(os.getcwd() + "/tests/segmentation/testimages/train/groundtruth/image"+str(i)+".jpg", Y_true) for i in range(0,5): imsave(os.getcwd() + "/tests/segmentation/testimages/test/image/image"+str(i)+".jpg", X_true) imsave(os.getcwd() + "/tests/segmentation/testimages/test/groundtruth/image"+str(i)+".jpg", Y_true) configs = {"use_algorithm": "SemanticSegmentation", "path": "./tests/segmentation/testimages/", "pretrained_weights": False, "batchsize": 1, "iterations_over_dataset": 1, "image_size": False, "evaluation": False} pipeline = GetPipeLine(configs) pipeline.run() K.clear_session() assert (os.path.isfile(os.getcwd() + "/tests/segmentation/testimages/logs/pretrained_weights.hdf5")) # Make sure the networks has changed something for i in range(0, 5): assert (X_true != np.array((imread(os.getcwd() + "/tests/segmentation/testimages/results/image"+str(i)+".jpg_predict.tif")).astype("uint8"))).all #Delete created test data if os.path.exists(os.getcwd()+"/tests/segmentation/testimages") and os.path.isdir(os.getcwd()+"/tests/segmentation/testimages"): shutil.rmtree(os.getcwd()+"/tests/segmentation/testimages")
def start_learning(configs): logging.info("Start learning") logging.info(configs["use_algorithm"]) pipeline = GetPipeLine(configs) pipeline.run() K.clear_session()
def test_Classification(): os.makedirs(os.getcwd() + "/tests/classification/testimages/train/image/", exist_ok=True) os.makedirs(os.getcwd() + "/tests/classification/testimages/train/groundtruth/", exist_ok=True) os.makedirs(os.getcwd() + "/tests/classification/testimages/test/image/", exist_ok=True) os.makedirs(os.getcwd() + "/tests/classification/testimages/test/groundtruth/", exist_ok=True) X_true = np.ones((32, 32)) with open( os.getcwd() + "/tests/classification/testimages/train/groundtruth/" + 'groundtruth.csv', 'w') as writeFile: writer = csv.writer(writeFile) writer.writerow(['filename', 'groundtruth']) for i in range(0, 20): imsave( os.getcwd() + "/tests/classification/testimages/train/image/image" + str(i) + ".jpg", X_true) writer.writerow(["image" + str(i) + ".jpg", str(1)]) with open( os.getcwd() + "/tests/classification/testimages/test/groundtruth/" + 'groundtruth.csv', 'w') as writeFile: writer = csv.writer(writeFile) writer.writerow(['filename', 'groundtruth']) for i in range(0, 5): imsave( os.getcwd() + "/tests/classification/testimages/test/image/image" + str(i) + ".jpg", X_true) writer.writerow(["image" + str(i) + ".jpg", str(1)]) configs = { "use_algorithm": "Classification", "path": "./tests/classification/testimages/", "batchsize": 1, "iterations_over_dataset": 1, "num_classes": 2, "evaluation": False } pipeline = GetPipeLine(configs) pipeline.run() K.clear_session() # Make sure the networks has changed something assert ( os.path.isfile(os.getcwd() + "/tests/classification/testimages/results/results.csv")) #Delete created test data if os.path.exists(os.getcwd() + "/tests/classification/testimages") and os.path.isdir( os.getcwd() + "/tests/classification/testimages"): shutil.rmtree(os.getcwd() + "/tests/classification/testimages")