generated from Felipehonorato1/Best-README-Template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.py
37 lines (27 loc) · 1.16 KB
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# ESSE ARQUIVO BUILD TEM QUE BAIXAR O MODELO, PRÉ-PROCESSAR OS DADOS E GERAR O ARQUIVO YAML
from src.downloader import Downloader
from src.preprocess import Preprocessor
from utils.build_utils import allocate_split, create_yaml, stratified_sampling
import argparse
def get_build_args():
parser = argparse.ArgumentParser()
parser.add_argument("file_id", type=str)
return parser.parse_args()
if __name__ == "__main__":
downloader = Downloader()
downloader.run()
print("")
processor = Preprocessor()
processor.run()
print("")
create_yaml(train_path="images/train",
val_path="images/val",
test_path="images/test",
labels=processor.labels)
images_train, images_else, labels_train, labels_else = stratified_sampling(
processor.images_files, processor.labels, test_ratio=0.3)
images_val, images_test, labels_val, labels_test = stratified_sampling(
images_else, processor.labels, test_ratio=100 / len(images_else))
allocate_split("train", images_train, labels_train)
allocate_split("val", images_val, labels_val)
allocate_split("test", images_test, labels_test)