wko-on-cloud-n/research/unet.ipynb
Maciej Sobkowiak 59fe53fa40 adsdfasdga
2022-02-17 03:04:00 +01:00

40 KiB
Raw Blame History

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
---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\unet.ipynb Cell 9' in <module>
     <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> model_name = "models/unet.h5"
     <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> modelcheckpoint = ModelCheckpoint(model_name,
     <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>                                   monitor='val_loss',
     <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>                                   mode='auto',
     <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>                                   verbose=1,
     <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>                                   save_best_only=True)
---> <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> history = model.fit_generator(train_gen,
     <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>                     validation_data=val_gen,
     <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>                     epochs=EPOCHS,
     <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>                     steps_per_epoch=100,
     <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>                     validation_steps = 100,
     <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>                     shuffle=True,
     <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> )

File c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\keras\engine\training.py:2209, in Model.fit_generator(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)
   <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> """Fits the model on data yielded batch-by-batch by a Python generator.
   <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> 
   <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> DEPRECATED:
   <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>   `Model.fit` now supports generators, so there is no longer any need to use
   <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>   this endpoint.
   <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> """
   <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> warnings.warn(
   <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>     '`Model.fit_generator` is deprecated and '
   <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>     'will be removed in a future version. '
   <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>     'Please use `Model.fit`, which supports generators.',
   <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>     stacklevel=2)
-> <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> return self.fit(
   <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>     generator,
   <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>     steps_per_epoch=steps_per_epoch,
   <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>     epochs=epochs,
   <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>     verbose=verbose,
   <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>     callbacks=callbacks,
   <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>     validation_data=validation_data,
   <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>     validation_steps=validation_steps,
   <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>     validation_freq=validation_freq,
   <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>     class_weight=class_weight,
   <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>     max_queue_size=max_queue_size,
   <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>     workers=workers,
   <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>     use_multiprocessing=use_multiprocessing,
   <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>     shuffle=shuffle,
   <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>     initial_epoch=initial_epoch)

File c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\keras\utils\traceback_utils.py:67, in filter_traceback.<locals>.error_handler(*args, **kwargs)
     <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> except Exception as e:  # pylint: disable=broad-except
     <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>   filtered_tb = _process_traceback_frames(e.__traceback__)
---> <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>   raise e.with_traceback(filtered_tb) from None
     <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> finally:
     <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>   del filtered_tb

File c:\Users\masob\Desktop\STUDIA\WIDZENIE KOMPUTEROWE\Projekt ON CLOUD\cloud-detection-challenge\venv\lib\site-packages\tensorflow\python\eager\execute.py:54, in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
     <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> try:
     <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>   ctx.ensure_initialized()
---> <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>   tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
     <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>                                       inputs, attrs, num_outputs)
     <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> except core._NotOkStatusException as e:
     <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>   if name is not None:

InvalidArgumentError: 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]