Spaces:
Runtime error
Runtime error
File size: 1,874 Bytes
97dcf92 |
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 38 39 40 41 42 43 44 |
# Copy the all the data from external, augmented and raw folders to combined folder
import os
import shutil
import uuid
from configs import *
shutil.rmtree(COMBINED_DATA_DIR + "1/", ignore_errors=True)
for disease in CLASSES:
# check if the original folder exists
if os.path.exists(RAW_DATA_DIR + "1/" + disease):
print("Copying raw data for disease: ", disease)
if not os.path.exists(COMBINED_DATA_DIR + "1/" + disease):
os.makedirs(COMBINED_DATA_DIR + "1/" + disease)
for file in os.listdir(RAW_DATA_DIR + "1/" + disease):
random_name = str(uuid.uuid4()) + ".png"
shutil.copy(
RAW_DATA_DIR + "1/" + disease + "/" + file,
COMBINED_DATA_DIR + "1/" + disease + "/" + random_name,
)
if os.path.exists(EXTERNAL_DATA_DIR + "1/" + disease):
print("Copying external data for disease: ", disease)
if not os.path.exists(COMBINED_DATA_DIR + "1/" + disease):
os.makedirs(COMBINED_DATA_DIR + "1/" + disease)
for file in os.listdir(EXTERNAL_DATA_DIR + "1/" + disease):
random_name = str(uuid.uuid4()) + ".png"
shutil.copy(
EXTERNAL_DATA_DIR + "1/" + disease + "/" + file,
COMBINED_DATA_DIR + "1/" + disease + "/" + random_name,
)
if os.path.exists(AUG_DATA_DIR + "1/" + disease):
print("Copying augmented data for disease: ", disease)
if not os.path.exists(COMBINED_DATA_DIR + "1/" + disease):
os.makedirs(COMBINED_DATA_DIR + "1/" + disease)
for file in os.listdir(AUG_DATA_DIR + "1/" + disease):
random_name = str(uuid.uuid4()) + ".png"
shutil.copy(
AUG_DATA_DIR + "1/" + disease + "/" + file,
COMBINED_DATA_DIR + "1/" + disease + "/" + random_name,
)
|