This file contains 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
DateTime=`date "+%Y-%m-%d %H:%M"` | |
echo $DateTime |
This file contains 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
# credit: https://stackoverflow.com/a/44228436/4031135 | |
from pathlib import Path | |
p = Path('.') | |
# all subdirectories in the current directory, not recursive | |
list_subdirs = [f.name for f in p.iterdir() if f.is_dir()] | |
list_subdirs = sorted(list_subdirs, reverse=True) | |
for subdir in list_subdirs: |
This file contains 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
# credit: https://stackoverflow.com/a/44228436/4031135 | |
from pathlib import Path | |
p = Path('.') | |
# all subdirectories in the current directory, not recursive | |
list_subdirs = [f.name for f in p.iterdir() if f.is_dir()] | |
list_subdirs.sort() | |
for subdir in list_subdirs: |
This file contains 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 python | |
import argparse | |
import imageio | |
parser = argparse.ArgumentParser() | |
parser.add_argument('input', default='image.png', | |
help="Path to the input image to be cropped") | |
parser.add_argument('--output', |
This file contains 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 | |
def rgb_to_greyscale(image): | |
return np.dot(image[...,:3], [0.2989, 0.5870, 0.1140]) |
This file contains 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 rmse(a, b): | |
# Root MSE (Mean Squared Error) | |
return np.sqrt(np.mean(np.square(np.subtract(a, b, dtype=np.float32)))) |
This file contains 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
file = open('path/to/file', 'r') | |
count = 0 | |
while True: | |
line = file.readline() | |
if not line: | |
break | |
# do something here | |
This file contains 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 datetime | |
def pickle_vars(var1, var2): | |
pickle_file_path = 'zimnica/pickled_vars_' + datetime.datetime.now().strftime("%Y%m%d_%H%M%S") + '.pickle' | |
try: | |
pickle.dump((var1, var2), open(pickle_file_path, "wb")) | |
except Exception as e: | |
print("Problem while trying to pickle: ", str(e)) | |
This file contains 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 max_pool(image, pool_size=8): | |
""" | |
Fast implementation of max pooling, given the following is true: | |
- the length of image shape is 3 | |
- the image is channels-last | |
- pooling height, width, and stride are all equal (pool_size) | |
- height % pool_size == 0 | |
- width % pool_size == 0 | |
Code taken and adjusted from: max_pool_forward_reshape() in https://github.com/mratsim/Arraymancer/issues/174 |
This file contains 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 | |
image_3ch = np.repeat(image_1ch, 3, axis=1).reshape((image_1ch.shape[0], image_1ch.shape[1], 3)) |
NewerOlder