This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
def make_blur(img): | |
# image = cv2.imread(img) | |
ksize = (10, 10) | |
blur = cv2.blur(img, ksize) | |
return blur |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50/50 [==============================] - 109s 2s/step - loss: 0.2327 - acc: 0.4357 - val_loss: 0.2934 - val_acc: 0.4747 - lr: 1.0000e-04 | |
Epoch 80/200 | |
50/50 [==============================] - ETA: 0s - loss: 0.2390 - acc: 0.4316 | |
Epoch 00080: val_loss did not improve from 0.28716 | |
Training: epoch 80 ends at 20:04:06.414791 | |
50/50 [==============================] - 114s 2s/step - loss: 0.2390 - acc: 0.4316 - val_loss: 0.3010 - val_acc: 0.5238 - lr: 1.0000e-04 | |
Epoch 81/200 | |
50/50 [==============================] - ETA: 0s - loss: 0.2358 - acc: 0.4557 | |
Epoch 00081: val_loss did not improve from 0.28716 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Model: "model_3" | |
__________________________________________________________________________________________________ | |
Layer (type) Output Shape Param # Connected to | |
================================================================================================== | |
input_4 (InputLayer) [(None, 512, 512, 3) 0 | |
__________________________________________________________________________________________________ | |
conv2d_54 (Conv2D) (None, 512, 512, 16) 448 input_4[0][0] | |
__________________________________________________________________________________________________ | |
dropout_27 (Dropout) (None, 512, 512, 16) 0 conv2d_54[0][0] | |
__________________________________________________________________________________________________ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Trainable params: 1,941,139 | |
class automaticmaplabelling(): | |
def __init__(self, modelPath, width=512,height=512,channels=3): | |
self.modelPath=modelPath | |
self.IMG_WIDTH=width | |
self.IMG_HEIGHT=height | |
self.IMG_CHANNELS=channels | |
self.model = self.U_net() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model_name = "models/"+"Unet_purple_background.h5" | |
modelcheckpoint = ModelCheckpoint(model_name, | |
monitor='val_loss', | |
mode='auto', | |
verbose=1, | |
save_best_only=True) | |
lr_callback = ReduceLROnPlateau(min_lr=0.000001) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model = get_model() | |
model.summary() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
class MyCustomCallback(tf.keras.callbacks.Callback): | |
def on_train_begin(self, epoch, logs={}): | |
res_dir = "intermediate_results_purple_background" | |
try: | |
os.makedirs(res_dir) | |
except: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_model(): | |
in1 = Input(shape=(IMG_HEIGHT, IMG_WIDTH, 3 )) | |
conv1 = Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(in1) | |
conv1 = Dropout(0.2)(conv1) | |
conv1 = Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(conv1) | |
pool1 = MaxPooling2D((2, 2))(conv1) | |
conv2 = Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(pool1) | |
conv2 = Dropout(0.2)(conv2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cv2_imshow(x[0] * 255.) | |
cv2_imshow(y['seg'][0] * 255.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def keras_generator_train_val_test(batch_size, choice="train"): | |
if choice == "train": | |
X = X_train | |
y = y_train | |
elif choice == "val": | |
X = X_val | |
y = y_val | |
elif choice == "test": | |
X = X_test |