Skip to content

Instantly share code, notes, and snippets.

View shashwatwork's full-sized avatar
💭
Happy Learning!

SHASHWAT TIWARI shashwatwork

💭
Happy Learning!
View GitHub Profile
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)
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)
import cv2
img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img =cv2.resize(img_rgb,(1300,275))
plt.imshow(img)
import cv2
img_bgr = cv2.imread('../DATA/00-puppy.jpg')
plt.imshow(img_bgr)
import cv2
image = cv2.imread("00-puppy.jpg")
img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
plt.imshow(img_rgb)
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)
@shashwatwork
shashwatwork / load.py
Last active September 14, 2019 22:18
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)
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)
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
# 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])