def load_data(path, max_count=-1): X = [] y = [] for file in os.listdir(path): if len(X) == max_count: break if file.endswith(".jpg"): fname = join(path, file) img = cv2.cvtColor(cv2.imread(fname), cv2.COLOR_BGR2RGB) gx, gy, _ = find_goals(img)[0] size = img.shape y.append(np.array([gx/size[0], gy/size[1]])) img = cv2.resize(img, (160, 120)) X.append(img.transpose(2, 1, 0)/255) X = np.array(X) y = np.array(y) return X, y
def target_preprocess(img): x, y, _ = filter_test.find_goals(img)[0] return x/img.shape[0], y/img.shape[1]