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 | |
| import matplotlib.pyplot as plt | |
| # Two images | |
| img1 = cv2.imread('../DATA/dog_backpack.png') | |
| img2 = cv2.imread('../DATA/watermark_no_copy.png') | |
| # Check image shape should be same | |
| img1.shape | |
| img2.shape | |
| img1 = cv2.cvtColor(img1, cv2.COLOR_BGR2RGB) | |
| img2 = cv2.cvtColor(img2, cv2.COLOR_BGR2RGB) |
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
| img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) | |
| # Along central x axis | |
| new_img = cv2.flip(img_rgb,0) | |
| plt.imshow(new_img) | |
| # Along central y axis | |
| new_img = cv2.flip(img_rgb,1) | |
| plt.imshow(new_img) |
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 | |
| img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) | |
| img =cv2.resize(img_rgb,(1300,275)) | |
| plt.imshow(img) |
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 | |
| img_bgr = cv2.imread('../DATA/00-puppy.jpg') | |
| plt.imshow(img_bgr) |
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 | |
| image = cv2.imread("00-puppy.jpg") | |
| img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) | |
| plt.imshow(img_rgb) |
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 flask import Flask, request, render_template | |
| import pickle | |
| import numpy as np | |
| from flask_restful import Api,Resource | |
| from flask_cors import CORS | |
| import seaborn as se | |
| import pandas as pd | |
| app = Flask(__name__) | |
| CORS(app) |
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 pickle | |
| import pandas as pd | |
| import numpy as np | |
| from sklearn.ensemble import RandomForestClassifier | |
| with open('rf_nn.pkl', 'rb') as handle: | |
| rf_nn = pickle.load(handle) | |
| # no we can call various methods over mlp_nn as as: | |
| # Let X_test be the feature (UNIX timestamp) for which we want to predict the output | |
| result = rf_nn.predict(X_test) |
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 pickle | |
| import pandas as pd | |
| import numpy as np | |
| from sklearn.ensemble import RandomForestClassifier | |
| rf_nn = RandomForestClassifier() | |
| rf_nn.fit(X_train,y_train) | |
| with open('rf_nn.pkl', 'wb') as handle: | |
| pickle.dump(rf_nn, handle, pickle.HIGHEST_PROTOCOL) | |
| # pickle.HIGHEST_PROTOCOL using the highest available protocol | |
| # (we used wb to open file as binary and use a higher pickling protocol) |
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
| class GAN(): | |
| def __init__(self): | |
| self.img_rows = 28 | |
| self.img_cols = 28 | |
| self.channels = 1 | |
| self.img_shape = (self.img_rows, self.img_cols, self.channels) | |
| optimizer = Adam(0.0002, 0.5) | |
| # Build and compile the discriminator |
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
| # lstm autoencoder recreate sequence | |
| from numpy import array | |
| from keras.models import Sequential | |
| from keras.layers import LSTM | |
| from keras.layers import Dense | |
| from keras.layers import RepeatVector | |
| from keras.layers import TimeDistributed | |
| from keras.utils import plot_model | |
| # define input sequence | |
| sequence = array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]) |