This file contains hidden or 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
| # Plot training & validation accuracy values | |
| plt.plot(results.history['iou_coef']) | |
| plt.plot(results.history['val_iou_coef']) | |
| plt.title('Model accuracy') | |
| plt.ylabel('IOU') | |
| plt.xlabel('Epoch') | |
| plt.legend(['Train', 'Test'], loc='upper left') | |
| plt.show() | |
| # Plot training & validation loss values |
This file contains hidden or 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
| from skimage.exposure import cumulative_distribution | |
| import numpy as np | |
| def cdf(im): | |
| ''' | |
| computes the CDF of an image im as 2D numpy ndarray | |
| ''' | |
| c, b = cumulative_distribution(im) | |
| # pad the beginning and ending pixels and their CDF values |
This file contains hidden or 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
| from skimage.exposure import cumulative_distribution | |
| import numpy as np | |
| def cdf(im): | |
| ''' | |
| computes the CDF of an image im as 2D numpy ndarray | |
| ''' | |
| c, b = cumulative_distribution(im) | |
| # pad the beginning and ending pixels and their CDF values |
This file contains hidden or 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 numpy as np | |
| def hist_match(source, template): | |
| """ | |
| Adjust the pixel values of a grayscale image such that its histogram | |
| matches that of a target image | |
| Arguments: | |
| ----------- | |
| source: np.ndarray |
This file contains hidden or 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 tensorflow as tf | |
| from keras.models import Sequential | |
| from tensorflow.keras.layers import ( | |
| Conv2D, MaxPooling2D, Flatten, | |
| Dense, Dropout, Input | |
| ) | |
| image_input = Input(shape=(100, 100, 3), name='input_layer') | |
| conv_1 = Conv2D(8, | |
| kernel_size=(3, 3), |
This file contains hidden or 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 as cv | |
| import numpy as np | |
| def nothing(x): | |
| pass | |
| # Color trackbars |
This file contains hidden or 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
| df1 = df.copy() | |
| var_types = pd.DataFrame(df1.dtypes.index, columns = ['Variable']) | |
| lst = [] | |
| for col in df1.columns: | |
| try: | |
| df1[col] = df1[col].astype(float) | |
| lst.append(False) | |
| except: | |
| try: |
This file contains hidden or 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 pandas as pd | |
| variables = [] | |
| rlst = [] | |
| for i in range(0, len(variables)): | |
| clst = [] | |
| for j in range(0, len(variables)): | |
| if i != j: | |
| clst.append( round(df[variables[i]].corr(df[variables[j]]), 3)) |
This file contains hidden or 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
| from scipy.optimize import curve_fit | |
| # interpolate | |
| df_int[field] = df[field].interpolate(method='piecewise_polynomial') | |
| ''' | |
| 'linear’, ‘time’, ‘index’, ‘values’, ‘nearest’, ‘zero’, | |
| ‘slinear’, ‘quadratic’, ‘cubic’, ‘barycentric’, ‘krogh’, ‘polynomial’, ‘spline’ ‘piecewise_polynomial’, ‘pchip’} | |
| ''' |
This file contains hidden or 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
| # %matplotlib inline | |
| from matplotlib import pyplot as plt | |
| plt.rcParams['figure.figsize'] = (10, 8) | |
| fig = plt.figure(figsize=(25, 15)) | |
| cols = 5 | |
| rows = np.ceil(float(data_train.shape[1]) / cols) | |
| for i, column in enumerate(data_train.columns): | |
| ax = fig.add_subplot(rows, cols, i + 1) |