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
| template<class T> | |
| struct Container | |
| { | |
| union wrapper { | |
| constexpr wrapper(): b() {} | |
| ~wrapper() = default; | |
| bool b; | |
| T t; | |
| } w; |
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
| template<class _Tp> | |
| struct __shared_if | |
| { | |
| typedef shared_ptr<_Tp> __shared_single; | |
| }; | |
| template<class _Tp> | |
| struct __shared_if<_Tp[]> | |
| { | |
| typedef shared_ptr<typename remove_extent<_Tp>::type> __shared_array_unknown_bound; |
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
| # theme | |
| POWERLEVEL9K_MODE='nerdfont-complete' | |
| POWERLEVEL9K_PROMPT_ON_NEWLINE=true | |
| POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='' | |
| POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='' | |
| POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR='' | |
| POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR='' | |
| POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="%F{blue}\u256D\u2500%F{white}" | |
| POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%F{blue}\u2570\uf460%F{white} " | |
| POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(root_indicator dir dir_writable_joined) |
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
| input_layer = blocks[0] | |
| input_shape = (int(input_layer['shape']), | |
| int(input_layer['shape']), | |
| int(input_layer['channels'])) | |
| true_boxes = Input(shape=(1, 1, 1, TRUE_BOX_BUFFER , 4)) | |
| model_input = Input(input_shape) | |
| x = model_input | |
| skip_connection = None |
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 | |
| from cv2 import COLOR_RGB2GRAY | |
| from skimage.feature import hog | |
| from sklearn.model_selection import train_test_split | |
| from sklearn.svm import LinearSVC | |
| import matplotlib.pyplot as plt | |
| from glob import glob |
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
| test_image = cv2.imread('test.jpg', COLOR_RGB2GRAY) # load test image | |
| test_image = cv2.resize(test_image, (200, 400)) # resize | |
| # get all sliding windows we want | |
| search_windows = \ | |
| sliding_window(test_image, y_stop=200, window=(64, 64), overlap=(.7, .7)) + \ | |
| sliding_window(test_image, y_stop=250, window=(80, 80), overlap=(.6, .6)) + \ | |
| sliding_window(test_image, y_stop=300, window=(96, 96), overlap=(.5, .5)) + \ | |
| sliding_window(test_image, y_stop=350, window=(128, 128), overlap=(.4, .4)) |
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 randcolorvalue(): | |
| return float(randint(0, 255)) / 255 | |
| def randcolor(): | |
| return randcolorvalue(), randcolorvalue(), randcolorvalue() | |
| def draw_boxes(image, boxes): | |
| image = np.copy(image) |
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
| X = np.vstack([people_features, not_people_features]) | |
| y = np.concatenate([np.ones(people_len), np.zeros(not_people_len)]) | |
| train_x, test_x, train_y, test_y = train_test_split(X, y, test_size=0.2, shuffle=True) | |
| classifier = LinearSVC(verbose=1) | |
| classifier.fit(train_x, train_y) | |
| print('Accuracy: %s' % classifier.score(test_x, test_y)) |
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 get_hog_features(image, visualize=False): | |
| features = hog( | |
| image, | |
| orientations=9, | |
| pixels_per_cell=(8, 8), | |
| cells_per_block=(2, 2), | |
| visualize=visualize, | |
| feature_vector=True, | |
| block_norm='L1' | |
| ) |
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
| people_glob = glob('dataset/people/*.png') | |
| background_glob = glob('dataset/not-people/*.png') | |
| people = [] | |
| not_people = [] | |
| for filename in people_glob: | |
| image = cv2.imread(filename, COLOR_RGB2GRAY) | |
| image = cv2.resize(image, (64, 64)) | |
| people.append(image) |