<jupyter_start><jupyter_text>Train your Unet with membrane datamembrane data is in folder membrane/, it is a binary classification task.The input shape of image and mask are the same :(batch_size,rows,cols,channel = 1)  Train with data generator<jupyter_code>TIMES = 50
TRAIN_SHAPE = 30
BATCH_SIZE = 2
STEP_PER_EPOCH = TIMES*TRAIN_SHAPE/BATCH_SIZE
EPOCHS = 5
IMG_SIZE = 256
TARGET_SIZE = (IMG_SIZE,IMG_SIZE)
data_gen_args = dict(rotation_range=0.2,
                    width_shift_range=0.05,
                    height_shift_range=0.05,
                    shear_range=0.05,
                    zoom_range=0.05,
                    horizontal_flip=True,
                    fill_mode='nearest')
myGene = trainGenerator(BATCH_SIZE,'data/membrane/train',
                        image_folder='image',
                        mask_folder='label',
                        aug_dict = data_gen_args,
                        flag_multi_class = False,
                        num_class = 2,
                        save_to_dir = None,
                        target_size = TARGET_SIZE,
                        seed = 42)
model = unet()
model_checkpoint = ModelCheckpoint('unet_membrane.hdf5', monitor='loss',verbose=1, save_best_only=True)
model.fit_generator(myGene,steps_per_epoch=STEP_PER_EPOCH,epochs=EPOCHS,callbacks=[model_checkpoint])<jupyter_output>Found 30 images belonging to 1 classes.
Found 30 images belonging to 1 classes.
WARNING:tensorflow:sample_weight modes were coerced from
  ...
    to  
  ['...']
Train for 750.0 steps
Epoch 1/5
749/750 [============================>.] - ETA: 0s - loss: 0.2633 - accuracy: 0.8862
Epoch 00001: loss improved from inf to 0.26314, saving model to unet_membrane.hdf5
750/750 [==============================] - 69s 92ms/step - loss: 0.2631 - accuracy: 0.8863
Epoch 2/5
749/750 [============================>.] - ETA: 0s - loss: 0.1785 - accuracy: 0.9222
Epoch 00002: loss improved from 0.26314 to 0.17844, saving model to unet_membrane.hdf5
750/750 [==============================] - 68s 91ms/step - loss: 0.1784 - accuracy: 0.9222
Epoch 3/5
749/750 [============================>.] - ETA: 0s - loss: 0.1523 - accuracy: 0.9330
Epoch 00003: loss improved from 0.17844 to 0.15232, saving model to unet_membrane.hdf5
750/750 [==============================] - 69s 91ms/step - loss: 0.1523 - accuracy: 0.9330
E[...]<jupyter_text>Train with npy file<jupyter_code>#imgs_train,imgs_mask_train = geneTrainNpy("data/membrane/train/aug/","data/membrane/train/aug/")
#model.fit(imgs_train, imgs_mask_train, batch_size=2, nb_epoch=10, verbose=1,validation_split=0.2, shuffle=True, callbacks=[model_checkpoint])<jupyter_output><empty_output><jupyter_text>test your model and save predicted results<jupyter_code>testGene = testGenerator("data/membrane/test",num_image=30)
model = unet()
model.load_weights("unet_membrane.hdf5")
results = model.predict_generator(testGene,verbose=1)
saveResult("data/membrane/predict",results)<jupyter_output>30/Unknown - 1s 33ms/step
{'fraction_non_alphanumeric': 0.1595460614152203, 'fraction_numerical': 0.07309746328437917, 'mean_word_length': 3.413843888070692, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '65388', 'license': 'MIT', 'n_tokens_mistral': 1167, 'n_tokens_neox': 974, 'n_words': 210, 'path': 'trainUnet.ipynb', 'repo_name': 'handsomekiwi/unet_paper_implement', 'size': '2996'}