From 3d686e05fa93e6c04ee46dc4c45aef7e20efbb15 Mon Sep 17 00:00:00 2001 From: colourfulspring Date: Mon, 19 Feb 2024 00:00:01 +0800 Subject: [PATCH] add: update python data export json file --- tensorboard_data_acquire.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tensorboard_data_acquire.py diff --git a/tensorboard_data_acquire.py b/tensorboard_data_acquire.py new file mode 100644 index 00000000..fa4993cd --- /dev/null +++ b/tensorboard_data_acquire.py @@ -0,0 +1,31 @@ +import os +import shutil + +# Source directory where files are located +source_dir = "./results" + +# Destination directory where files will be copied +destination_dir = "./tensorboard_results" + +# Find all files in the source directory starting with "events" +files = [] +for root, dirs, filenames in os.walk(source_dir): + for filename in filenames: + if filename.startswith('events'): + files.append(os.path.join(root, filename)) + +# Loop through each file found +for file_path in files: + # Get the directory where the file is located relative to the source directory + relative_dir = os.path.relpath(os.path.dirname(file_path), source_dir) + + # Create the corresponding directory structure in the destination directory + os.makedirs(os.path.join(destination_dir, relative_dir), exist_ok=True) + + # Copy the file to the destination directory, preserving the directory structure + shutil.copy(file_path, os.path.join(destination_dir, relative_dir)) + + # Print out the copied files + print(f"Copied {file_path} to {os.path.join(destination_dir, relative_dir)}") + +print("Copy operation completed.")