kohya_ss icon indicating copy to clipboard operation
kohya_ss copied to clipboard

[Feature Request] Loading the json configuration without a modal window

Open ruSauron opened this issue 1 year ago • 4 comments

This request is a bit related to #262.

By Server, I will mean the computer where the kohya_gui.py is running. By remote device, I will mean another computer that has the webui GUI open in a browser.

The --listen mode implies the ability to control the workout from another device.

The Open button opens a modal window on the server. I can't find a way to load the config on the remote device without accessing the server instead of having to re-set them manually.

I see 2 ways to implement this, but it doesn't have to be this way.

  1. Quite simple. Add a new (4th) button, which without "Open file" window tries to load the json file from the path specified in the textbox. Possible error messages such as no such file should be visible in the browser on the remote device. There should be no visible events on the server, except for a possible log to the console. It would also be great to read the path to this json file from the address bar, for example, http://127.0.0.1:7861/?__theme=dark&__json=D:\AI\Lora\myconfig.json That would also solve issue #262

  2. Completely change the way the Configuration file interface works. If webui is not opened from 127.0.0.1 / localhost or if you have some special parameter in your address bar the "Open" button should open dialog on remote device instead of server, then save json from remote device to temporary server folder and then read configuration from this file. The "Save as..." button should then download the json file into the download on the remote device.

ruSauron avatar Mar 10 '23 22:03 ruSauron

Yeah... it is annoying me also... especially when I paste the path to the json file and it still open the dialog... I will try to implement the 4th button one can use to open the file in the field... and if it is not present it will simply. output an error message to the consele.

I will also add an option to pass the json file to the gui to load the config on startup... this should take cake of both of those ;-)

bmaltais avatar Mar 10 '23 23:03 bmaltais

OK, I have implemented the 1st thing to load the config without opening the modal window. It is pushed to the dev branch.

Now... for the 2nd it is a bit harder because each tab has it's own config... and there is nothing in the config file that specify what tab the config is for... so I can't just take an argument to load the config... I would need two arguments... one for the target tab and another for the config... this is not nice... any suggestion?

bmaltais avatar Mar 11 '23 01:03 bmaltais

OK, I have implemented the 1st thing to load the config without opening the modal window. It is pushed to the dev branch.

Now... for the 2nd it is a bit harder because each tab has it's own config... and there is nothing in the config file that specify what tab the config is for... so I can't just take an argument to load the config... I would need two arguments... one for the target tab and another for the config... this is not nice... any suggestion?

Tried the new load button - it works perfect, thanks!

At the moment you can use the configuration file path from the URL as the default text value on all the tabs and not load the json until the user clicks on a newly added button on the tab they want

I think that 2nd argument is fine. In this case, if the tab is specified, you can immediately try to apply the configuration from the specified json file &__mode= dreambooth / lora / ti / finetune you could also give the option to use a short designation, such as &__mode=1-4

instead of "mode" is also a fine word is "tab"

ruSauron avatar Mar 11 '23 01:03 ruSauron

Now... for the 2nd it is a bit harder because each tab has it's own config... and there is nothing in the config file that specify what tab the config is for... so I can't just take an argument to load the config... I would need two arguments... one for the target tab and another for the config... this is not nice... any suggestion?

I am not sure if I get it right and I am a python beginner,but when I was trying to implement batch inpainting feature for automatic's webUI, in modules\ui.py specifically for his repo,he was using a seperate structure for each tab,some element id for tabs,but then he implemented some shared feature for the tabs,so it bacame easy like you can edit some numbers for the tabs from 1 to n'th tab,and then that shared feature is carried to that tab. I can't remember the exact code now,but it is like a class and you inherit some part from that class to another. The reason I tell this cos before you needed to edit code and do a lot of stuff manually but with that shared option,numbers could be used.

So maybe like filename structure and tabs to be named with number or the tab name. If it is a dreambooth config ,config file can be saved with some specific filename my_config_dreambooth.json, my_config_dreambooth_0001.json , if it is lora config,my_config_lora.json etc. Regex can be used to check filename,or maybe you can embed the config info inside the json file completely. So json file shall have some entry,that it is lora,finetune or whatever.Then when it is loading the config,it first checks the config file type then it loads it for the related tab.

but when I use for example this bat file :

@echo off

set VENV_DIR=.\venv set PYTHON=python git pull call %VENV_DIR%\Scripts\activate.bat start "firefox.exe" http://127.0.0.1:7870 %PYTHON% lora_gui.py --server_port 7870

this exclusively calls lora gui,so there are no extra tabs for dreambooth or whatever,then the numbers can fail.Then the viable or reliable option is to save the info directly into the json file itself and if not, filenames shall be automatically renamed when saving with a suffix maybe.

FlowDownTheRiver avatar Mar 11 '23 15:03 FlowDownTheRiver

OK, I have implemented the 1st thing to load the config without opening the modal window. It is pushed to the dev branch.

Now... for the 2nd it is a bit harder because each tab has it's own config... and there is nothing in the config file that specify what tab the config is for... so I can't just take an argument to load the config... I would need two arguments... one for the target tab and another for the config... this is not nice... any suggestion?

Check this, please: https://github.aiurs.co/gradio-app/gradio/discussions/2949

Direct link to example: https://huggingface.co/spaces/radames/gradio-url-params?__theme=light&text_input=My+test+string&second_option=12345678

Source code: https://huggingface.co/spaces/radames/gradio-url-params/blob/main/app.py

ruSauron avatar Mar 26 '23 20:03 ruSauron