Spaces:
Runtime error
Runtime error
File size: 722 Bytes
f1a0ba2 c4bc1f2 41e1e17 c4bc1f2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from img2art_search.constants import BASE_PATH
import os
import numpy as np
def get_data_from_local():
left_or_top_data = [f"{BASE_PATH}/splits/left_or_top/{fn}" for fn in os.listdir(f"{BASE_PATH}/splits/left_or_top")]
x = np.array(left_or_top_data)
y = np.array([ex.replace("left_or_top", "right_or_bottom") for ex in x])
data = np.array([x, y])
return data
def split_train_val_test(data, test_size, val_size):
train_size = 1 - test_size - val_size
SPLIT = int(data.shape[1] * train_size)
TEST_SPLIT = SPLIT + int(data.shape[1] * test_size)
train = data[:, :SPLIT]
validation = data[:, SPLIT:TEST_SPLIT]
test = data[:, TEST_SPLIT:]
return train, validation, test
|