diff --git a/dreambooth_gui.py b/dreambooth_gui.py index f41a1dd..1e76d89 100644 --- a/dreambooth_gui.py +++ b/dreambooth_gui.py @@ -25,6 +25,8 @@ from library.common_gui import ( gradio_config, gradio_source_model, set_legacy_8bitadam, +) +from library.tensorboard_gui import ( gradio_tensorboard, start_tensorboard, stop_tensorboard, diff --git a/finetune_gui.py b/finetune_gui.py index 55278ee..7777a7f 100644 --- a/finetune_gui.py +++ b/finetune_gui.py @@ -19,6 +19,8 @@ from library.common_gui import ( color_aug_changed, run_cmd_training, set_legacy_8bitadam, +) +from library.tensorboard_gui import ( gradio_tensorboard, start_tensorboard, stop_tensorboard, diff --git a/library/common_gui.py b/library/common_gui.py index 941cc3b..25089af 100644 --- a/library/common_gui.py +++ b/library/common_gui.py @@ -3,59 +3,12 @@ import os import gradio as gr from easygui import msgbox import shutil -import subprocess -import time folder_symbol = '\U0001f4c2' # 📂 refresh_symbol = '\U0001f504' # 🔄 save_style_symbol = '\U0001f4be' # 💾 document_symbol = '\U0001F4C4' # 📄 -##### -# tensorboard section -##### - -tensorboard_proc = None # I know... bad but heh - -def start_tensorboard(logging_dir): - global tensorboard_proc - - if not os.listdir(logging_dir): - print("Error: log folder is empty") - return - - run_cmd = f'tensorboard.exe --logdir "{logging_dir}"' - - print(run_cmd) - if tensorboard_proc is not None: - print("Tensorboard is already running. Terminating existing process before starting new one...") - stop_tensorboard() - - # Start background process - print('Starting tensorboard...') - tensorboard_proc = subprocess.Popen(run_cmd) - - # Wait for some time to allow TensorBoard to start up - time.sleep(5) - - # Open the TensorBoard URL in the default browser - print('Opening tensorboard url in browser...') - import webbrowser - webbrowser.open('http://localhost:6006') - -def stop_tensorboard(): - print('Stopping tensorboard process...') - tensorboard_proc.kill() - print('...process stopped') - -def gradio_tensorboard(): - with gr.Row(): - button_start_tensorboard = gr.Button('Start tensorboard') - button_stop_tensorboard = gr.Button('Stop tensorboard') - - return(button_start_tensorboard, button_stop_tensorboard) - -##### def get_dir_and_file(file_path): dir_path, file_name = os.path.split(file_path) diff --git a/library/tensorboard_gui.py b/library/tensorboard_gui.py new file mode 100644 index 0000000..fa90a1c --- /dev/null +++ b/library/tensorboard_gui.py @@ -0,0 +1,46 @@ +import os +import gradio as gr +from easygui import msgbox +import subprocess +import time + +tensorboard_proc = None # I know... bad but heh + +def start_tensorboard(logging_dir): + global tensorboard_proc + + if not os.listdir(logging_dir): + print("Error: log folder is empty") + msgbox(msg="Error: log folder is empty") + return + + run_cmd = f'tensorboard.exe --logdir "{logging_dir}"' + + print(run_cmd) + if tensorboard_proc is not None: + print("Tensorboard is already running. Terminating existing process before starting new one...") + stop_tensorboard() + + # Start background process + print('Starting tensorboard...') + tensorboard_proc = subprocess.Popen(run_cmd) + + # Wait for some time to allow TensorBoard to start up + time.sleep(5) + + # Open the TensorBoard URL in the default browser + print('Opening tensorboard url in browser...') + import webbrowser + webbrowser.open('http://localhost:6006') + +def stop_tensorboard(): + print('Stopping tensorboard process...') + tensorboard_proc.kill() + print('...process stopped') + +def gradio_tensorboard(): + with gr.Row(): + button_start_tensorboard = gr.Button('Start tensorboard') + button_stop_tensorboard = gr.Button('Stop tensorboard') + + return(button_start_tensorboard, button_stop_tensorboard) diff --git a/lora_gui.py b/lora_gui.py index eb0b567..b1f3f34 100644 --- a/lora_gui.py +++ b/lora_gui.py @@ -25,13 +25,15 @@ from library.common_gui import ( gradio_source_model, run_cmd_training, set_legacy_8bitadam, - gradio_tensorboard, - start_tensorboard, - stop_tensorboard, ) from library.dreambooth_folder_creation_gui import ( gradio_dreambooth_folder_creation_tab, ) +from library.tensorboard_gui import ( + gradio_tensorboard, + start_tensorboard, + stop_tensorboard, +) from library.dataset_balancing_gui import gradio_dataset_balancing_tab from library.utilities import utilities_tab from library.merge_lora_gui import gradio_merge_lora_tab diff --git a/textual_inversion_gui.py b/textual_inversion_gui.py index 3bb8b93..aaa4df3 100644 --- a/textual_inversion_gui.py +++ b/textual_inversion_gui.py @@ -25,6 +25,8 @@ from library.common_gui import ( gradio_config, gradio_source_model, set_legacy_8bitadam, +) +from library.tensorboard_gui import ( gradio_tensorboard, start_tensorboard, stop_tensorboard, diff --git a/tools/rename_depth_mask.py b/tools/rename_depth_mask.py new file mode 100644 index 0000000..97efdea --- /dev/null +++ b/tools/rename_depth_mask.py @@ -0,0 +1,21 @@ +import os +import argparse + +# Define the command line arguments +parser = argparse.ArgumentParser(description='Rename files in a folder') +parser.add_argument('folder', metavar='folder', type=str, help='the folder containing the files to rename') + +# Parse the arguments +args = parser.parse_args() + +# Get the list of files in the folder +files = os.listdir(args.folder) + +# Loop through each file in the folder +for file in files: + # Check if the file has the expected format + if file.endswith('-0000.png'): + # Get the new file name + new_file_name = file[:-9] + '.mask' + # Rename the file + os.rename(os.path.join(args.folder, file), os.path.join(args.folder, new_file_name))