Add authentication support

This commit is contained in:
bmaltais 2022-12-21 09:05:06 -05:00
parent 1bc5089db8
commit aa5d13f9a7
3 changed files with 888 additions and 853 deletions

View File

@ -11,3 +11,8 @@ You can find the dreambooth solution spercific [Dreambooth README](README_dreamb
## Finetune
You can find the finetune solution spercific [Finetune README](README_finetune.md)
## Change history
* 12/21 (v9.7) update:
- add optional GUI authentication support via: `python fine_tune.py --username=<name> --password=<password>`

View File

@ -10,6 +10,7 @@ import os
import subprocess
import pathlib
import shutil
import argparse
from library.dreambooth_folder_creation_gui import (
gradio_dreambooth_folder_creation_tab,
)
@ -472,17 +473,17 @@ def set_pretrained_model_name_or_path_input(value, v2, v_parameterization):
return value, v2, v_parameterization
def UI(username, password):
css = ''
css = ''
if os.path.exists('./style.css'):
if os.path.exists('./style.css'):
with open(os.path.join('./style.css'), 'r', encoding='utf8') as file:
print('Load CSS...')
css += file.read() + '\n'
interface = gr.Blocks(css=css)
interface = gr.Blocks(css=css)
with interface:
with interface:
dummy_true = gr.Label(value=True, visible=False)
dummy_false = gr.Label(value=False, visible=False)
with gr.Tab('Dreambooth'):
@ -958,5 +959,19 @@ with interface:
],
)
# Show the interface
interface.launch()
# Show the interface
if not username == '':
interface.launch(auth=(username, password))
else:
interface.launch()
if __name__ == '__main__':
# torch.cuda.set_per_process_memory_fraction(0.48)
parser = argparse.ArgumentParser()
parser.add_argument("--username", type=str, default='', help="Username for authentication")
parser.add_argument("--password", type=str, default='', help="Password for authentication")
args = parser.parse_args()
UI(username=args.username, password=args.password)

View File

@ -5,6 +5,7 @@ import os
import subprocess
import pathlib
import shutil
import argparse
# from easygui import fileopenbox, filesavebox, diropenbox, msgbox
from library.basic_caption_gui import gradio_basic_caption_gui_tab
@ -99,9 +100,8 @@ def save_configuration(
}
# Save the data to the selected file
# with open(file_path, 'w') as file:
# json.dump(variables, file)
# msgbox('File was saved...')
with open(file_path, 'w') as file:
json.dump(variables, file)
return file_path
@ -386,17 +386,18 @@ def remove_doublequote(file_path):
return file_path
def UI(username, password):
css = ''
css = ''
if os.path.exists('./style.css'):
if os.path.exists('./style.css'):
with open(os.path.join('./style.css'), 'r', encoding='utf8') as file:
print('Load CSS...')
css += file.read() + '\n'
interface = gr.Blocks(css=css)
interface = gr.Blocks(css=css)
with interface:
with interface:
dummy_true = gr.Label(value=True, visible=False)
dummy_false = gr.Label(value=False, visible=False)
with gr.Tab('Finetuning'):
@ -791,5 +792,19 @@ with interface:
gradio_convert_model_tab()
# Show the interface
interface.launch()
# Show the interface
if not username == '':
interface.launch(auth=(username, password))
else:
interface.launch()
if __name__ == '__main__':
# torch.cuda.set_per_process_memory_fraction(0.48)
parser = argparse.ArgumentParser()
parser.add_argument("--username", type=str, default='', help="Username for authentication")
parser.add_argument("--password", type=str, default='', help="Password for authentication")
args = parser.parse_args()
UI(username=args.username, password=args.password)