-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatasetpreprocessing.py
More file actions
24 lines (17 loc) · 853 Bytes
/
datasetpreprocessing.py
File metadata and controls
24 lines (17 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
import configuration as config
import shutil
for folder in os.scandir(config.ROOT_DIR):
if folder.is_dir():
image_folder = os.path.join(config.ROOT_DIR, folder.name, "images")
masks_folder = os.path.join(config.ROOT_DIR, folder.name, "masks")
for file in os.scandir(image_folder):
_, extension = os.path.splitext(file)
new_file = os.path.join(folder, file.name.replace(".png", "-raw") + extension)
shutil.copyfile(file.path, new_file)
shutil.rmtree(image_folder)
for file in os.scandir(masks_folder):
_, extension = os.path.splitext(file)
new_file = os.path.join(folder, file.name.replace(".png", "-mask") + extension)
shutil.copyfile(file.path, new_file)
shutil.rmtree(masks_folder)