Update tensorboard

This commit is contained in:
bmaltais 2023-03-01 13:14:47 -05:00
parent dfd155a8e1
commit 1e3055c895
7 changed files with 78 additions and 50 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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,

View File

@ -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))