diff --git a/README.md b/README.md index a7e58b6..d13cd5b 100644 --- a/README.md +++ b/README.md @@ -177,7 +177,9 @@ This will store your a backup file with your current locally installed pip packa ## Change History * 2023/03/05 (v21.2.0): - - Added new `Additional parameters` under the `Advanced Configuration` section of the `Training parameters` tab.to allow for the specifications of parameters not handles by the GUI. + - Add option to print LoRA trainer command without executing it + - Add support for samples during trainin via a new `Sample images config` accordion in the `Training parameters` tab. + - Added new `Additional parameters` under the `Advanced Configuration` section of the `Training parameters` tab to allow for the specifications of parameters not handles by the GUI. - Added support for sample as a new Accordion under the `Training parameters` tab. More info about the prompt options can be found here: https://github.com/kohya-ss/sd-scripts/issues/256#issuecomment-1455005709 - There may be problems due to major changes. If you cannot revert back to a previous version when problems occur (`git checkout `). - Dependencies are updated, Please [upgrade](#upgrade) the repo. diff --git a/lora_gui.py b/lora_gui.py index 6aa0d96..35fefd6 100644 --- a/lora_gui.py +++ b/lora_gui.py @@ -269,6 +269,7 @@ def open_configuration( def train_model( + print_only, pretrained_model_name_or_path, v2, v_parameterization, @@ -337,6 +338,8 @@ def train_model( sample_sampler, sample_prompts,additional_parameters, ): + print_only_bool = True if print_only.get('label') == 'True' else False + if pretrained_model_name_or_path == '': msgbox('Source model information is missing') return @@ -571,20 +574,23 @@ def train_model( output_dir, ) - print(run_cmd) - - # Run the command - if os.name == 'posix': - os.system(run_cmd) + if print_only_bool: + print('Here is the trainer command as a reference. It will not be executed:') + print(run_cmd) else: - subprocess.run(run_cmd) + print(run_cmd) + # Run the command + if os.name == 'posix': + os.system(run_cmd) + else: + subprocess.run(run_cmd) - # check if output_dir/last is a folder... therefore it is a diffuser model - last_dir = pathlib.Path(f'{output_dir}/{output_name}') + # check if output_dir/last is a folder... therefore it is a diffuser model + last_dir = pathlib.Path(f'{output_dir}/{output_name}') - if not last_dir.is_dir(): - # Copy inference model for v2 if required - save_inference_file(output_dir, v2, v_parameterization, output_name) + if not last_dir.is_dir(): + # Copy inference model for v2 if required + save_inference_file(output_dir, v2, v_parameterization, output_name) def lora_tab( @@ -877,6 +883,8 @@ def lora_tab( gradio_verify_lora_tab() button_run = gr.Button('Train model', variant='primary') + + button_print = gr.Button('Print training command') # Setup gradio tensorboard buttons button_start_tensorboard, button_stop_tensorboard = gradio_tensorboard() @@ -985,7 +993,13 @@ def lora_tab( button_run.click( train_model, - inputs=settings_list, + inputs=[dummy_db_false] + settings_list, + show_progress=False, + ) + + button_print.click( + train_model, + inputs=[dummy_db_true] + settings_list, show_progress=False, )