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
# Create .bash_profile in your home directory and add these lines: | |
export SHELL=/bin/zsh | |
exec /bin/zsh -l |
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 | |
def frame_count(video_path, manual=False): | |
def manual_count(handler): | |
frames = 0 | |
while True: | |
status, frame = handler.read() | |
if not status: | |
break | |
frames += 1 |
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
# freezing layers !!! | |
#------------------------------------------------------------------------------- | |
def freeze_until(net, param_name): | |
found_name = False | |
for name, params in net.named_parameters(): | |
if name == param_name: | |
found_name = True | |
params.requires_grad = found_name | |
# freeze_until(net, "layer3.0.conv1.weight") |
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 | |
import torch | |
def generate_images_pack_matrix(in_root, train=False): | |
# make a seed with numpy generator | |
seed = np.random.randint(2147483647) | |
in_root = Path(in_root) | |
img_paths = [i for i in list(in_root.iterdir()) if i.is_file() and not i.name.startswith(".")] | |
img_paths.sort(key=lambda x:int(x.stem)) |
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
#!/usr/bin/env python3 | |
""" | |
Library providing convenient classes and methods for writing data to files. | |
""" | |
import sys | |
import json | |
import pickle | |
try: | |
import yaml |
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 collections | |
pred_type = collections.namedtuple('prediction_type', ['slice', 'color']) | |
pred_types = {'face': pred_type(slice(0, 17), (0.682, 0.780, 0.909, 0.5)), | |
'eyebrow1': pred_type(slice(17, 22), (1.0, 0.498, 0.055, 0.4)), | |
'eyebrow2': pred_type(slice(22, 27), (1.0, 0.498, 0.055, 0.4)), | |
'nose': pred_type(slice(27, 31), (0.345, 0.239, 0.443, 0.4)), | |
'nostril': pred_type(slice(31, 36), (0.345, 0.239, 0.443, 0.4)), | |
'eye1': pred_type(slice(36, 42), (0.596, 0.875, 0.541, 0.3)), | |
'eye2': pred_type(slice(42, 48), (0.596, 0.875, 0.541, 0.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 matplotlib | |
matplotlib.use('Agg') # Call in python file | |
# %matplotlib inline # Call in Jupyter Notebook | |
# Draw line plot | |
def draw2D(X, Y, order, xname, yname, params, xlim=None, ylim=None, rcparams=None, legend_loc=0, show=False): | |
title = params['title'] | |
colors = params['colors'] | |
markers = params['markers'] |
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
#For Python 2.x | |
reload(foo) | |
#For Python 3.x | |
import importlib | |
import foo #import the module here, so that it can be reloaded. | |
importlib.reload(foo) |
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, os | |
import numpy as np | |
# Only opencv3 is supported! | |
if not (cv2.__version__).startswith('3.'): | |
raise ValueError('Only opencv 3. is supported!') | |
def crop_video(pathIn, pathOut, pos, size): | |
""" |
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
// 3 ways to start a snackbar without pass in a view. | |
Snackbar.make(mapFragment.getView(), "Click the pin for more options", Snackbar.LENGTH_LONG).show(); | |
getWindow().getDecorView().getRootView(); | |
Snackbar.make(getWindow().getDecorView().getRootView(), "Click the pin for more options", Snackbar.LENGTH_LONG).show(); |
NewerOlder