Skip to content

Instantly share code, notes, and snippets.

@theibrr
theibrr / neural_style_transfer.py
Created April 21, 2022 21:03
Neural Style Transfer
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 16 00:59:57 2022
@author: Ibrahim Kovan
https://ibrahimkovan.medium.com/
"""
import tensorflow as tf
import numpy as np
import tensorflow.keras.preprocessing.image as process_im
@theibrr
theibrr / optimization.py
Created April 13, 2022 13:47
How to Select Loss Function and Activation Function for Classification Problems?
"""
@author: Ibrahim Kovan
https://ibrahimkovan.medium.com/
"""
#%% Libraries
import numpy as np
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from sklearn import preprocessing
from sklearn.model_selection import train_test_split
@theibrr
theibrr / optimization.py
Last active April 13, 2022 13:47
How to Select Loss Function and Activation Function for Classification Problems?
"""
@author: Ibrahim Kovan
https://ibrahimkovan.medium.com/
"""
import numpy as np
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from sklearn import preprocessing
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
@theibrr
theibrr / U-Net.py
Created January 3, 2022 00:42
Semantic Segmentation of Aerial Imagery captured by a Drone using U-Net
"""14"""
fig, ax = plt.subplots(5, 4, figsize = (16,20))
for i in range(0,5):
test_img_number = random.randint(0, len(x_test))
test_img = x_test[test_img_number]
ground_truth=y_test_argmax[test_img_number]
test_img_input=np.expand_dims(test_img, 0)
prediction = (model.predict(test_img_input))
predicted_img=np.argmax(prediction, axis=3)[0,:,:]
@theibrr
theibrr / U-Net.py
Created January 3, 2022 00:41
Semantic Segmentation of Aerial Imagery captured by a Drone using U-Net
#%% pre-trained model
"""10"""
BACKBONE = 'resnet34'
preprocess_input = sm.get_preprocessing(BACKBONE)
# preprocess input
x_train_new = preprocess_input(x_train)
x_test_new = preprocess_input(x_test)
# define model
@theibrr
theibrr / U-Net.py
Created January 3, 2022 00:37
Semantic Segmentation of Aerial Imagery captured by a Drone using U-Net
#%% pre-trained model
"""10"""
BACKBONE = 'resnet34'
preprocess_input = sm.get_preprocessing(BACKBONE)
# preprocess input
x_train_new = preprocess_input(x_train)
x_test_new = preprocess_input(x_test)
# define model
@theibrr
theibrr / U-Net.py
Created January 3, 2022 00:37
Semantic Segmentation of Aerial Imagery captured by a Drone using U-Net
#%% U-Net
"""6"""
img_height = x_train.shape[1]
img_width = x_train.shape[2]
img_channels = x_train.shape[3]
metrics=['accuracy', jacard]
def get_model():
@theibrr
theibrr / U-Net.py
Created January 3, 2022 00:36
Semantic Segmentation of Aerial Imagery captured by a Drone using U-Net
# -*- coding: utf-8 -*-
"""
@author: Ibrahim Kovan
https://ibrahimkovan.medium.com/
dataset: http://www.dronedataset.icg.tugraz.at/
dataset link: https://www.kaggle.com/awsaf49/semantic-drone-dataset
License: CC0: Public Domain
"""
@theibrr
theibrr / architecture.py
Created January 3, 2022 00:31
U-Net Architecture
# -*- coding: utf-8 -*-
"""
@author: Ibrahim Kovan
https://ibrahimkovan.medium.com/
"""
from tensorflow.keras.models import Model
from tensorflow.keras.layers import Input, Conv2D, MaxPooling2D, UpSampling2D, concatenate, Conv2DTranspose, BatchNormalization, Dropout, Lambda
from tensorflow.keras import backend as K
def multiclass_unet_architecture(n_classes=2, height=256, width=256, channels=3):
@theibrr
theibrr / lstm_and_dnn.py
Created December 21, 2021 02:46
germany power consumption
# -*- coding: utf-8 -*-
"""
@author: Ibrahim Kovan
https://ibrahimkovan.medium.com/
License: CC0: Public Domain
Dataset: https://www.kaggle.com/francoisraucent/western-europe-power-consumption
"""
""" [1] """
import pandas as pd