<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>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(2,base_path+'/train','image','label',data_gen_args,save_to_dir = None)
model = unet()
model_checkpoint = ModelCheckpoint(base_path+'/unet.hdf5', monitor='loss',verbose=1, save_best_only=True)
model.fit_generator(myGene,steps_per_epoch=4,epochs=5,callbacks=[model_checkpoint])<jupyter_output>Found 30 images belonging to 1 classes.
Found 30 images belonging to 1 classes.
Epoch 1/5
4/4 [==============================] - 10s 2s/step - loss: 0.6504 - accuracy: 0.9987

Epoch 00001: loss improved from inf to 0.60515, saving model to /home/koosk/data/images/renard/unet/HCT116_Intro_Replicate1/unet.hdf5
Epoch 2/5
4/4 [==============================] - 9s 2s/step - loss: 0.0576 - accuracy: 1.0000

Epoch 00002: loss improved from 0.60515 to 0.03493, saving model to /home/koosk/data/images/renard/unet/HCT116_Intro_Replicate1/unet.hdf5
Epoch 3/5
4/4 [==============================] - 11s 3s/step - loss: 3.4308e-04 - accuracy: 1.0000

Epoch 00003: loss improved from 0.03493 to 0.00022, saving model to /home/koosk/data/images/renard/unet/HCT116_Intro_Replicate1/unet.hdf5
Epoch 4/5
4/4 [==============================] - 11s 3s/step - loss: 8.7667e-06 - accuracy: 1.0000

Epoch 00004: loss improved from 0.00022 to 0.00001, saving model to /home/koosk/data/images/renard/unet/HCT116_Intro_Re[...]<jupyter_text>Train with npy file<jupyter_code># imgs_train,imgs_mask_train = geneTrainNpy("data/HCT116_Intro_Replicate1/train/aug/","data/HCT116_Intro_Replicate1/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(base_path+"/test",4)
model = unet()
model.load_weights(base_path+"/unet.hdf5")
results = model.predict(testGene,4,verbose=1)
saveResult(base_path+"/test",results)
for i in range(4):
    r = results[i]
    print(f"{np.min(r)} {np.max(r)} {np.max(r)*255}")<jupyter_output>0.0 9.049035934634297e-14 2.307504163331746e-11
0.0 3.906134224962443e-05 0.00996064227365423
0.0 6.282516598868919e-26 1.6020417327115744e-23
0.0 0.0 0.0
{'fraction_non_alphanumeric': 0.16160877513711153, 'fraction_numerical': 0.1170018281535649, 'mean_word_length': 4.711899791231732, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '488294', 'license': 'MIT', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1021, 'n_words': 191, 'path': 'trainUnet.ipynb', 'repo_name': 'koosk/unet', 'size': '2735'}