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 cal_IoU(img, lab, nb_class): | |
| for i in range(nb_class): | |
| mask1 = (img == (i + 1)).astype('uint8') | |
| mask2 = (lab == (i + 1)).astype('uint8') | |
| mask_and = cv2.bitwise_and(mask1, mask2) | |
| mask_or = cv2.bitwise_or(mask1, mask2) | |
| s1 = np.sum(mask_and) | |
| s2 = np.sum(mask_or) |
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 re | |
| def is_img_file(file_name): | |
| file_name = str(file_name) | |
| file_name = file_name.lower() | |
| return re.search('\.bmp$', file_name) or re.search('\.png$', file_name) or \ | |
| re.search('\.jpg$', file_name) or re.search('\.jpeg', file_name) or re.search('\.tiff', file_name) |
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 pandas as pd | |
| import numpy as np | |
| def load_train_data(path='inputFiles/train.csv'): | |
| x = [] | |
| y = [] | |
| data = pd.read_csv(path) | |
| data = data.values | |
| data_num = len(data) | |
| for i in range(0, data_num): |
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 rgb2gray(img): | |
| assert np.ndim(img) == 3 | |
| img = color.rgb2gray(img) * 255 | |
| img = np.uint8(img) | |
| return img |
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 interval_peek(arr): | |
| ''' | |
| Find all no-zero continuous interval, then in every interval, set all element 0 except the peek. | |
| :param arr: | |
| :return: | |
| ''' | |
| left = 0 | |
| arr_len = len(arr) | |
| res = arr[:] | |
| while left < arr_len: |
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 os, sys | |
| curPath = os.path.abspath(os.path.dirname(__file__)) | |
| rootPath = os.path.split(curPath)[0] | |
| print('rootPath:{}'.format(rootPath)) | |
| sys.path.append(rootPath) |
NewerOlder