40 KiB
40 KiB
import shutil
import tensorflow as tf
from tensorflow.keras import backend as K
from tensorflow.keras.layers import Activation, Lambda, GlobalAveragePooling2D, concatenate
from tensorflow.keras.layers import UpSampling2D, Conv2D, Dropout, MaxPooling2D, Conv2DTranspose
from tensorflow.keras.layers import Dense, Flatten, Input
from tensorflow.keras.models import Model, Sequential, load_model
from tensorflow.keras.callbacks import ModelCheckpoint, ReduceLROnPlateau
from tensorflow.keras.preprocessing.image import ImageDataGenerator
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import cv2
import pickle
import random
import os
from src.metrics import IOU
from src.consts import JPG_IMAGES, RGB_DIR, MASK_DIR
# we create two instances with the same arguments
print(os.path.exists('./images/rgb'))
img_size = (512,512)
rgb_dir = os.path.join("images", RGB_DIR)
mask_dir = os.path.join("images", MASK_DIR)
train_datagen = ImageDataGenerator(rescale=1 / 255.0,
horizontal_flip=True,
vertical_flip=True,
validation_split=0.2)
# Provide the same seed and keyword arguments to the fit and flow methods
seed = 1
image_generator = train_datagen.flow_from_directory(
'./images/rgb',
class_mode=None,
# class_mode='binary',
seed=seed,
subset='training'
)
mask_generator = train_datagen.flow_from_directory(
'./images/mask',
class_mode=None,
seed=seed,
subset='training'
)
image_generator_val = train_datagen.flow_from_directory(
'./images/rgb',
class_mode=None,
# class_mode='binary',
seed=seed,
subset='validation'
)
mask_generator_val = train_datagen.flow_from_directory(
'./images/mask',
class_mode=None,
seed=seed,
subset='validation'
)
train_gen = zip(image_generator, mask_generator)
val_gen = zip(image_generator_val, mask_generator_val)
True Found 9399 images belonging to 1 classes. Found 9399 images belonging to 1 classes. Found 2349 images belonging to 1 classes. Found 2349 images belonging to 1 classes.
IMG_HEIGHT = 512
IMG_WIDTH = 512
# img_dir = '/images'
EPOCHS = 30
batch_size = 16
Unet model
class Unet():
def __init__(self, num_classes=1):
self.num_classes=num_classes
def build_model(self):
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)
conv2 = Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(conv2)
pool2 = MaxPooling2D((2, 2))(conv2)
conv3 = Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(pool2)
conv3 = Dropout(0.2)(conv3)
conv3 = Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(conv3)
pool3 = MaxPooling2D((2, 2))(conv3)
conv4 = Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(pool3)
conv4 = Dropout(0.2)(conv4)
conv4 = Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(conv4)
up1 = concatenate([UpSampling2D((2, 2))(conv4), conv3], axis=-1)
conv5 = Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(up1)
conv5 = Dropout(0.2)(conv5)
conv5 = Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(conv5)
up2 = concatenate([UpSampling2D((2, 2))(conv5), conv2], axis=-1)
conv6 = Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(up2)
conv6 = Dropout(0.2)(conv6)
conv6 = Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(conv6)
up2 = concatenate([UpSampling2D((2, 2))(conv6), conv1], axis=-1)
conv7 = Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(up2)
conv7 = Dropout(0.2)(conv7)
conv7 = Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(conv7)
segmentation = Conv2D(self.num_classes, (1, 1), activation='sigmoid', name='seg')(conv7)
#segmentation = Conv2D(3, (1, 1), activation='sigmoid', name='seg')(conv7)
model = Model(inputs=[in1], outputs=[segmentation])
return model
from src.loss import jaccard_loss
model = Unet(num_classes=1).build_model()
compile_params ={
'loss':jaccard_loss(smooth=90),
'optimizer':'rmsprop',
'metrics':[IOU]
}
model.compile(**compile_params)
tf.keras.utils.plot_model(model, show_shapes=True)
model_name = "models/unet.h5"
modelcheckpoint = ModelCheckpoint(model_name,
monitor='val_loss',
mode='auto',
verbose=1,
save_best_only=True)
history = model.fit_generator(train_gen,
validation_data=val_gen,
epochs=EPOCHS,
steps_per_epoch=100,
validation_steps = 100,
shuffle=True,
)
You must install pydot (`pip install pydot`) and install graphviz (see instructions at https://graphviz.gitlab.io/download/) for plot_model/model_to_dot to work.
C:\Users\masob\AppData\Local\Temp\ipykernel_21092\68410389.py:22: UserWarning: `Model.fit_generator` is deprecated and will be removed in a future version. Please use `Model.fit`, which supports generators. history = model.fit_generator(train_gen,
Epoch 1/30
[1;31m---------------------------------------------------------------------------[0m [1;31mInvalidArgumentError[0m Traceback (most recent call last) [1;32mc:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\unet.ipynb Cell 9'[0m in [0;36m<module>[1;34m[0m [0;32m <a href='vscode-notebook-cell:/c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/unet.ipynb#ch0000007?line=13'>14</a>[0m model_name [39m=[39m [39m"[39m[39mmodels/unet.h5[39m[39m"[39m [0;32m <a href='vscode-notebook-cell:/c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/unet.ipynb#ch0000007?line=14'>15</a>[0m modelcheckpoint [39m=[39m ModelCheckpoint(model_name, [0;32m <a href='vscode-notebook-cell:/c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/unet.ipynb#ch0000007?line=15'>16</a>[0m monitor[39m=[39m[39m'[39m[39mval_loss[39m[39m'[39m, [0;32m <a href='vscode-notebook-cell:/c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/unet.ipynb#ch0000007?line=16'>17</a>[0m mode[39m=[39m[39m'[39m[39mauto[39m[39m'[39m, [0;32m <a href='vscode-notebook-cell:/c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/unet.ipynb#ch0000007?line=17'>18</a>[0m verbose[39m=[39m[39m1[39m, [0;32m <a href='vscode-notebook-cell:/c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/unet.ipynb#ch0000007?line=18'>19</a>[0m save_best_only[39m=[39m[39mTrue[39;00m) [1;32m---> <a href='vscode-notebook-cell:/c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/unet.ipynb#ch0000007?line=21'>22</a>[0m history [39m=[39m model[39m.[39;49mfit_generator(train_gen, [0;32m <a href='vscode-notebook-cell:/c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/unet.ipynb#ch0000007?line=22'>23</a>[0m validation_data[39m=[39;49mval_gen, [0;32m <a href='vscode-notebook-cell:/c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/unet.ipynb#ch0000007?line=23'>24</a>[0m epochs[39m=[39;49mEPOCHS, [0;32m <a href='vscode-notebook-cell:/c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/unet.ipynb#ch0000007?line=24'>25</a>[0m steps_per_epoch[39m=[39;49m[39m100[39;49m, [0;32m <a href='vscode-notebook-cell:/c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/unet.ipynb#ch0000007?line=25'>26</a>[0m validation_steps [39m=[39;49m [39m100[39;49m, [0;32m <a href='vscode-notebook-cell:/c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/unet.ipynb#ch0000007?line=26'>27</a>[0m shuffle[39m=[39;49m[39mTrue[39;49;00m, [0;32m <a href='vscode-notebook-cell:/c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/unet.ipynb#ch0000007?line=27'>28</a>[0m ) File [1;32mc:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\keras\engine\training.py:2209[0m, in [0;36mModel.fit_generator[1;34m(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)[0m [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2197'>2198</a>[0m [39m"""Fits the model on data yielded batch-by-batch by a Python generator.[39;00m [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2198'>2199</a>[0m [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2199'>2200</a>[0m [39mDEPRECATED:[39;00m [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2200'>2201</a>[0m [39m `Model.fit` now supports generators, so there is no longer any need to use[39;00m [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2201'>2202</a>[0m [39m this endpoint.[39;00m [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2202'>2203</a>[0m [39m"""[39;00m [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2203'>2204</a>[0m warnings[39m.[39mwarn( [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2204'>2205</a>[0m [39m'[39m[39m`Model.fit_generator` is deprecated and [39m[39m'[39m [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2205'>2206</a>[0m [39m'[39m[39mwill be removed in a future version. [39m[39m'[39m [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2206'>2207</a>[0m [39m'[39m[39mPlease use `Model.fit`, which supports generators.[39m[39m'[39m, [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2207'>2208</a>[0m stacklevel[39m=[39m[39m2[39m) [1;32m-> <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2208'>2209</a>[0m [39mreturn[39;00m [39mself[39;49m[39m.[39;49mfit( [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2209'>2210</a>[0m generator, [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2210'>2211</a>[0m steps_per_epoch[39m=[39;49msteps_per_epoch, [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2211'>2212</a>[0m epochs[39m=[39;49mepochs, [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2212'>2213</a>[0m verbose[39m=[39;49mverbose, [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2213'>2214</a>[0m callbacks[39m=[39;49mcallbacks, [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2214'>2215</a>[0m validation_data[39m=[39;49mvalidation_data, [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2215'>2216</a>[0m validation_steps[39m=[39;49mvalidation_steps, [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2216'>2217</a>[0m validation_freq[39m=[39;49mvalidation_freq, [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2217'>2218</a>[0m class_weight[39m=[39;49mclass_weight, [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2218'>2219</a>[0m max_queue_size[39m=[39;49mmax_queue_size, [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2219'>2220</a>[0m workers[39m=[39;49mworkers, [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2220'>2221</a>[0m use_multiprocessing[39m=[39;49muse_multiprocessing, [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2221'>2222</a>[0m shuffle[39m=[39;49mshuffle, [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/engine/training.py?line=2222'>2223</a>[0m initial_epoch[39m=[39;49minitial_epoch) File [1;32mc:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\keras\utils\traceback_utils.py:67[0m, in [0;36mfilter_traceback.<locals>.error_handler[1;34m(*args, **kwargs)[0m [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/utils/traceback_utils.py?line=64'>65</a>[0m [39mexcept[39;00m [39mException[39;00m [39mas[39;00m e: [39m# pylint: disable=broad-except[39;00m [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/utils/traceback_utils.py?line=65'>66</a>[0m filtered_tb [39m=[39m _process_traceback_frames(e[39m.[39m__traceback__) [1;32m---> <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/utils/traceback_utils.py?line=66'>67</a>[0m [39mraise[39;00m e[39m.[39mwith_traceback(filtered_tb) [39mfrom[39;00m [39mNone[39m [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/utils/traceback_utils.py?line=67'>68</a>[0m [39mfinally[39;00m: [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/keras/utils/traceback_utils.py?line=68'>69</a>[0m [39mdel[39;00m filtered_tb File [1;32mc:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\tensorflow\python\eager\execute.py:54[0m, in [0;36mquick_execute[1;34m(op_name, num_outputs, inputs, attrs, ctx, name)[0m [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/tensorflow/python/eager/execute.py?line=51'>52</a>[0m [39mtry[39;00m: [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/tensorflow/python/eager/execute.py?line=52'>53</a>[0m ctx[39m.[39mensure_initialized() [1;32m---> <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/tensorflow/python/eager/execute.py?line=53'>54</a>[0m tensors [39m=[39m pywrap_tfe[39m.[39mTFE_Py_Execute(ctx[39m.[39m_handle, device_name, op_name, [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/tensorflow/python/eager/execute.py?line=54'>55</a>[0m inputs, attrs, num_outputs) [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/tensorflow/python/eager/execute.py?line=55'>56</a>[0m [39mexcept[39;00m core[39m.[39m_NotOkStatusException [39mas[39;00m e: [0;32m <a href='file:///c%3A/Users/masob/Desktop/STUDIA/WIDZENIE%20KOMPUTEROWE/Projekt%20ON%20CLOUD/cloud-detection-challenge/venv/lib/site-packages/tensorflow/python/eager/execute.py?line=56'>57</a>[0m [39mif[39;00m name [39mis[39;00m [39mnot[39;00m [39mNone[39;00m: [1;31mInvalidArgumentError[0m: Graph execution error: Detected at node 'gradient_tape/model_6/concatenate_18/ConcatOffset' defined at (most recent call last): File "C:\Users\masob\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\masob\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\ipykernel_launcher.py", line 16, in <module> app.launch_new_instance() File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\traitlets\config\application.py", line 846, in launch_instance app.start() File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\ipykernel\kernelapp.py", line 677, in start self.io_loop.start() File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\tornado\platform\asyncio.py", line 199, in start self.asyncio_loop.run_forever() File "C:\Users\masob\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 596, in run_forever self._run_once() File "C:\Users\masob\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 1890, in _run_once handle._run() File "C:\Users\masob\AppData\Local\Programs\Python\Python39\lib\asyncio\events.py", line 80, in _run self._context.run(self._callback, *self._args) File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\ipykernel\kernelbase.py", line 461, in dispatch_queue await self.process_one() File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\ipykernel\kernelbase.py", line 450, in process_one await dispatch(*args) File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\ipykernel\kernelbase.py", line 357, in dispatch_shell await result File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\ipykernel\kernelbase.py", line 652, in execute_request reply_content = await reply_content File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\ipykernel\ipkernel.py", line 359, in do_execute res = shell.run_cell(code, store_history=store_history, silent=silent) File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\ipykernel\zmqshell.py", line 532, in run_cell return super().run_cell(*args, **kwargs) File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\IPython\core\interactiveshell.py", line 2768, in run_cell result = self._run_cell( File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\IPython\core\interactiveshell.py", line 2814, in _run_cell return runner(coro) File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\IPython\core\async_helpers.py", line 129, in _pseudo_sync_runner coro.send(None) File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\IPython\core\interactiveshell.py", line 3012, in run_cell_async has_raised = await self.run_ast_nodes(code_ast.body, cell_name, File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\IPython\core\interactiveshell.py", line 3191, in run_ast_nodes if await self.run_code(code, result, async_=asy): File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\IPython\core\interactiveshell.py", line 3251, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "C:\Users\masob\AppData\Local\Temp\ipykernel_21092\68410389.py", line 22, in <module> history = model.fit_generator(train_gen, File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\keras\engine\training.py", line 2209, in fit_generator return self.fit( File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\keras\utils\traceback_utils.py", line 64, in error_handler return fn(*args, **kwargs) File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\keras\engine\training.py", line 1384, in fit tmp_logs = self.train_function(iterator) File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\keras\engine\training.py", line 1021, in train_function return step_function(self, iterator) File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\keras\engine\training.py", line 1010, in step_function outputs = model.distribute_strategy.run(run_step, args=(data,)) File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\keras\engine\training.py", line 1000, in run_step outputs = model.train_step(data) File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\keras\engine\training.py", line 863, in train_step self.optimizer.minimize(loss, self.trainable_variables, tape=tape) File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\keras\optimizer_v2\optimizer_v2.py", line 530, in minimize grads_and_vars = self._compute_gradients( File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\keras\optimizer_v2\optimizer_v2.py", line 583, in _compute_gradients grads_and_vars = self._get_gradients(tape, loss, var_list, grad_loss) File "c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\keras\optimizer_v2\optimizer_v2.py", line 464, in _get_gradients grads = tape.gradient(loss, var_list, grad_loss) Node: 'gradient_tape/model_6/concatenate_18/ConcatOffset' All dimensions except 3 must match. Input 1 has shape [32 64 64 128] and doesn't match input 0 with shape [32 128 128 128]. [[{{node gradient_tape/model_6/concatenate_18/ConcatOffset}}]] [Op:__inference_train_function_8358]