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 nltk.tokenize import word_tokenize | |
import nltk | |
nltk.download('punkt') | |
def tokenize(string, to_lower=True, is_alpha=False): | |
"""Get string and return a list with tokens. | |
Token is the most simple chain of characters without any type of separation. | |
Args: |
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
# https://gist.github.com/RodrigoCMoraes/d76890fb8149182e2522014f308660ae | |
import keras | |
def read_model(arch_file, weights_file, optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy']): | |
"""Read custom keras model from files | |
Args: | |
arch_file(str): json file with model architecture | |
weights_file(str): h5 file with weights of model |
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
""" | |
Get frame from webcam and display it in real time | |
OpenCv version: 3.4.1 | |
Installed with command: pip install opencv-python | |
Python version: 3.6.5 :: Anaconda, Inc. | |
""" | |
import cv2 | |
""" |
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 tqdm import tqdm | |
import requests | |
chunk_size = 1024 | |
url = "http://www.nervenet.org/pdf/python3handson.pdf" | |
r = requests.get(url, stream = True) | |
total_size = int(r.headers['content-length']) |
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
# batch_size = 1024 | |
# num_epochs = 20 | |
# history = model.fit(X_train, train_labels, | |
# batch_size=batch_size, | |
# epochs=num_epochs, | |
# validation_data=(X_val, val_labels)) | |
# summarize history for accuracy | |
plt.plot(history.history['acc']) | |
plt.plot(history.history['val_acc']) |
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
#!/bin/bash | |
# install CUDA Toolkit v9.0 | |
# instructions from https://developer.nvidia.com/cuda-downloads (linux -> x86_64 -> Ubuntu -> 16.04 -> deb) | |
CUDA_REPO_PKG="cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb" | |
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/${CUDA_REPO_PKG} | |
sudo dpkg -i ${CUDA_REPO_PKG} | |
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub | |
sudo apt-get update | |
sudo apt-get -y install cuda-9-0 |
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 IPython.core.display import display, HTML | |
display(HTML("<style>.container { width:90% !important; }</style>")) | |
import warnings | |
warnings.filterwarnings('ignore') |
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
def pairwise_indexes(array, mode='comb'): | |
""" | |
Get indexes pairwise from array | |
Params: | |
array(list or numpy.array): array with shape(N,) where N is array size | |
mode: comb=combinatations or perm=permutations | |
Returns: | |
pairs(numpy.array): array with pair elements |
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
#!/bin/bash | |
# Delete all containers | |
docker rm $(docker ps -a -q) | |
# Delete all images | |
docker rmi $(docker images -q) |
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 numpy as np | |
screen_width, screen_height = 1920, 1080 | |
window_width, window_height = 1270, 720 | |
path = "template.jpeg" | |
image = cv2.imread(path) | |
image_width, image_height = image.shape[:2] |
OlderNewer