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
# Install cuda-10.0 because the newest one (for now the version 10.2) mismatchs the tensorflow 1.14.0 requirements | |
wget https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48_1.0-1_amd6 | |
dpkg -i cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48_1.0-1_amd6 | |
apt-key add /var/cuda-repo-10-0-local-10.0.130-410.48/7fa2af80.pub | |
apt-get install cuda | |
# This cuda version install nvidia v410 drivers. Remove it. |
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 line_profiler import LineProfiler | |
def do_profile(follow=[]): | |
def inner(func): | |
def profiled_func(*args, **kwargs): | |
try: | |
profiler = LineProfiler() | |
profiler.add_function(func) | |
for f in follow: | |
profiler.add_function(f) | |
profiler.enable_by_count() |
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://arxiv.org/pdf/1602.07360.pdf | |
# | |
from keras import backend as K | |
from keras.layers import Input, Convolution2D, MaxPooling2D, Activation, concatenate | |
from keras.layers import GlobalAveragePooling2D | |
from keras.models import Model | |
class SqueezeNet: | |
def __init__(self, input_shape, n_classes): |
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 glob import iglob | |
def return_impaths(dpath): | |
impaths = [list(iglob('{}/*.{}'.format(dpath, e))) for e in ['png', 'jpg', 'jpeg']] | |
impaths = sum(impaths, []) | |
return impaths |
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 | |
class inputGen: | |
def __init__(self, batch_size, X, y, shuffle=True): | |
self.batch_size = batch_size | |
self.X = X | |
self.y = y | |
self.cursor = 0 | |
self.n_samples = X.shape[0] | |
self.ids_sequence = np.arange(X.shape[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
import rlcompleter | |
import pdb | |
pdb.Pdb.complete = rlcompleter.Completer(locals()).complete | |
pdb.set_trace() | |
# Oneline to insert into code | |
import rlcompleter; import pdb; pdb.Pdb.complete = rlcompleter.Completer(locals()).complete; pdb.set_trace() |
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 argparse | |
def parse_args(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-e', type=str, help='Environment variable', required=True, dest='var1', | |
choices=['staging', 'production']) | |
parser.add_argument('--hypertuning', help='Run hypertuning process', action='store_true', dest='var2') | |
return parser.parse_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
# Easy to go tools | |
- http://www.robots.ox.ac.uk/~vgg/software/via/via-1.0.6.html | |
- https://github.com/virajmavani/semi-auto-image-annotation-tool | |
- https://labelbox.com/ -> Free until 2500 images per year. | |
# More references | |
- https://github.com/jsbroks/awesome-dataset-tools | |
- https://www.datasetlist.com/tools/ |
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 matplotlib.pyplot as plt | |
fig, axs = plt.subplots(4, figsize=(12, 12)) | |
for i in range(4): | |
axs[i].imshow(sample_masks[:, :, i]) | |
axs[i].axis('off') |
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
# Code snippet to train lightgbm models quickly, using the number of iterations based on CV | |
import lightgbm as lgb | |
lgb_dftrain = lgb.Dataset(features_train, target_train) | |
params = {'boosting_type': 'gbdt', | |
'objective': 'binary', | |
'enable_bundle': True, | |
'max_conflict_rate': 0, | |
'max_depth': 20, |