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
{ | |
"files.autoGuessEncoding": false, | |
"matlab.linterEncoding": "gb2312", | |
"[matlab]": { | |
"files.encoding": "gb2312" | |
} | |
} |
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
clc, clear, close all; | |
x = -10:0.1:10; | |
y = 1 ./ (1 + exp(-x)); %sigmoid | |
plot(x, y); | |
set(gca,'XAxisLocation','origin','YAxisLocation','origin'); |
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 color_kinds(img): | |
color_set = set() | |
if np.ndim(img) == 2: | |
channel_num = 1 | |
elif np.ndim(img) >= 3: | |
channel_num = np.size(img, np.ndim(img) - 1) | |
else: | |
print('unknow img format') | |
return color_set |
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 | |
import cv2 | |
import os | |
def cv2_imread(filename, mode=-1): | |
# 0:gray | |
# 1:rgb | |
# -1 any, read as the mode of source itself. | |
# like cv2.imread | |
cv_img = cv2.imdecode(np.fromfile(filename, dtype=np.uint8), mode) |
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 resize_contours(cnts, cnts_origin_shape_WxH:tuple, to_shape_WxH:tuple): | |
w_resize_rate = to_shape_WxH[0] / cnts_origin_shape_WxH[0] | |
h_resize_rate = to_shape_WxH[1] / cnts_origin_shape_WxH[1] | |
rate = (w_resize_rate, h_resize_rate) | |
for i in range(len(cnts)): | |
cnt = cnts[i] * rate | |
cnts[i] = np.array(cnt, dtype='int') | |
return cnts |
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 json | |
class NumpyEncoder(json.JSONEncoder): | |
""" Special json encoder for numpy types """ | |
def default(self, obj): | |
if isinstance(obj, (np.int_, np.intc, np.intp, np.int8, | |
np.int16, np.int32, np.int64, np.uint8, | |
np.uint16, np.uint32, np.uint64)): | |
return int(obj) | |
elif isinstance(obj, (np.float_, np.float16, np.float32, | |
np.float64)): |
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 cvt_unix_like_path(path): | |
if path is None: | |
return None | |
path = str(path) | |
unix_p_temp = path.replace('\\', '/') | |
unix_p = '' | |
pre = '' | |
for ch in unix_p_temp: | |
if not (ch == '/'): | |
unix_p = unix_p + ch |
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 matplotlib.pyplot as plt | |
import numpy as np | |
def show_images(images, cols = 1, titles = None): | |
"""Display a list of images in a single figure with matplotlib. | |
Parameters | |
--------- | |
images: List of np.arrays compatible with plt.imshow. | |
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 os | |
# GPU 00000000:88:00.0 | |
# FB Memory Usage | |
# Total : 8119 MiB | |
# Used : 2 MiB | |
# Free : 8117 MiB | |
# BAR1 Memory Usage | |
# Total : 256 MiB | |
# Used : 5 MiB | |
# Free : 251 MiB |
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
# Usage: | |
# $python file_count.py [option] | |
# options: | |
# -r count recursively | |
# -s[dir] workdir | |
# eg. | |
# #work on curent workdir: | |
# $python file_count.py | |
# #count recursively |
NewerOlder