Пример #1
0
            y.append(out_y)
            name = image_name + "_{}_{}".format(i, j)
            names.append(name)
            if out_dir is not None:
                Image.fromarray(out_x).save(
                    os.path.join(out_dir, name + ".png"))
    return x, y, names


x_paths = glob(os.path.join(train_dir, "*.png"))
x_paths.sort()
y_paths = glob(os.path.join(train_dir, "*.json"))
y_paths.sort()

label_file_path = os.path.join(train_dir, 'label.csv')
label = Label(label_file_path)

n_data = len(x_paths)
x = []
y = []
names = []
for i in tqdm(range(n_data)):
    x_path = x_paths[i]
    y_path = y_paths[i]
    _x, _y, _names = make_cut_xy_h5(
        x_path,
        y_path,
        data_type="polygon",
        out_image_size=(512, 512),
        label=label,
        # out_dir="../../data/train_data_256"
Пример #2
0
valid_extra_x_dirs = conf.get("valid_extra_x_dirs", None)
valid_y_dirs = conf["valid_y_dirs"]

batch_size = conf["batch_size"]
n_epochs = conf["n_epochs"]
output_activation = conf["output_activation"]
image_size = conf["image_size"]
loss = conf["loss"]
optimizer = conf["optimizer"]
metrics = conf["metrics"]
check_categorical_metrics = conf.get("check_categorical_metrics", "True")
class_weight = conf.get("class_weight", None)
use_tensorboard = conf.get("use_tensorboard", False)
use_batch_renorm = conf.get("use_batch_renorm", False)

label = Label(label_file_path)
if class_weight is not None:
    label.add_class_weight(class_weight)

hists_old = pd.read_csv(os.path.join(model_dir, "training_log.csv"))
initial_epoch = len(hists_old)

n_gpus = len(use_devices.split(','))
batch_size = batch_size * n_gpus

preprocess = keras.applications.xception.preprocess_input

# make train dataset
train_dataset, train_path_list = make_dataset(
    train_x_dirs,
    image_size,