LPX55's picture
chore: restructure new evalset
33341d9 verified
import os
import shutil
def move_real_images(source_dir, dest_dir):
if not os.path.exists(dest_dir):
os.makedirs(dest_dir)
# Walk through the source directory
for root, dirs, files in os.walk(source_dir):
if 'real' in dirs:
# Construct the full path to the `real` directory
real_dir = os.path.join(root, 'real')
model_folder_name = os.path.basename(root)
dest_model_dir = os.path.join(dest_dir, model_folder_name)
if not os.path.exists(dest_model_dir):
os.makedirs(dest_model_dir)
for file in os.listdir(real_dir):
source_file = os.path.join(real_dir, file)
dest_file = os.path.join(dest_model_dir, file)
shutil.move(source_file, dest_file)
print(f"Moved: {source_file} to {dest_file}")
def move_generated_images(source_dir):
# Walk through the source directory
for root, dirs, files in os.walk(source_dir):
# Check if the current directory is a `generated` directory
if 'generated' in dirs:
# Construct the full path to the `generated` directory
generated_dir = os.path.join(root, 'generated')
# Move all files from the `generated` directory to the parent directory
for file in os.listdir(generated_dir):
source_file = os.path.join(generated_dir, file)
dest_file = os.path.join(root, file)
# Move the file
shutil.move(source_file, dest_file)
print(f"Moved: {source_file} to {dest_file}")
def main():
source_dir = 'resampledSet'
real_dest_dir = 'real'
move_real_images(source_dir, real_dest_dir)
move_generated_images(source_dir)
if __name__ == "__main__":
main()