InvokeAI icon indicating copy to clipboard operation
InvokeAI copied to clipboard

[WebUI 2.3] Model Manager

Open blessedcoolant opened this issue 2 years ago • 7 comments

Model Manager for the WebUI

This PR intends to bring the ability to Add / Edit / Delete model configs directly from the WebUI along with features that streamline the entire process.

This is a very early draft and a lot is bound to change as we continue to work on it and explore ideas.

DONE:

  • [x] Add Initial Ability To Add New Models
  • [x] Add Initial Ability to Delete Existing Models
  • [x] Add Form Validation for Adding New Models
  • [x] Add Initial Ability to scan a folder for existing models.
  • [x] Add Folder Picker For Scanning Models.
  • [x] Cleanup the search_models function so it can be CLI ready.
  • [x] Add functionality to the Add Selected Button
  • [x] If a model in the loaded folder already exists in the config, disable the entry and show the model exists tag. -- This checks for the ckpt path and not the name itself. So it should be fool proof.
  • [x] Add toggle for displaying only non existing models.
  • [x] Add Alert Dialog for Delete Model so users dont accidentally delete entries.
  • [ ] Fix the tkinter window being shown on Mac --- NEED CONFIRMATION!!

TODO:

  • [ ] Add Initial Ability to Edit Existing Models
  • [ ] Style the Add Models Form

blessedcoolant avatar Dec 01 '22 08:12 blessedcoolant

Looks great so far. I'll have more comments after I've had some sleep.

lstein avatar Dec 03 '22 03:12 lstein

I tried this with openjourney and arcane and both of them throw the same error I've gotten in the past, some dictionary error. Also, in stable-diffusion-webui-docker, the folder select window doesn't open. You should consider using the chrome file system API as an alternative if that fails, or maybe https://developer.mozilla.org/en-US/docs/Web/API/File_and_Directory_Entries_API/Firefox_support

AskAlice avatar Dec 12 '22 11:12 AskAlice

I tried this with openjourney and arcane and both of them throw the same error I've gotten in the past, some dictionary error. Also, in stable-diffusion-webui-docker, the folder select window doesn't open. You should consider using the chrome file system API as an alternative if that fails, or maybe https://developer.mozilla.org/en-US/docs/Web/API/File_and_Directory_Entries_API/Firefox_support

We are still working out the best way to do this. At the moment, I'm forcing the file picker to come from Python because using the WebAPI is not an option for folder selection because for security reasons it'll never return absolute path and has no access to the file system in the browser. Which means we have make the user manually type the path rather than using a picker. Unless I'm totally missing a way where it returns an abs path.

blessedcoolant avatar Dec 12 '22 13:12 blessedcoolant

I tried this with openjourney and arcane and both of them throw the same error I've gotten in the past, some dictionary error. Also, in stable-diffusion-webui-docker, the folder select window doesn't open. You should consider using the chrome file system API as an alternative if that fails, or maybe developer.mozilla.org/en-US/docs/Web/API/File_and_Directory_Entries_API/Firefox_support

We are still working out the best way to do this. At the moment, I'm forcing the file picker to come from Python because using the WebAPI is not an option for folder selection because for security reasons it'll never return absolute path and has no access to the file system in the browser. Which means we have make the user manually type the path rather than using a picker. Unless I'm totally missing a way where it returns an abs path.

ahh I see. yeah.. If you want autocomplete, could be worth having the backend of the app scan the directory structure of the relevant directories/docker volume mounts, defaulting to the directory where the models are stored in.

By the way, what models have you imported successfully with this code?

AskAlice avatar Dec 12 '22 14:12 AskAlice

ahh I see. yeah.. If you want autocomplete, could be worth having the backend of the app scan the directory structure of the relevant directories/docker volume mounts, defaulting to the directory where the models are stored in.

Yep. That would limit the user to storing models in a single folder we specify. Trying to explore options where a user would be able to pick any the want. But we're also gonna revamp the way model handling is done in general so a user can submit folders and all of them would just get scanned.

By the way, what models have you imported successfully with this code?

All of them? I haven't had any problems on Windows. But I know there's some issues of the tkinter window lingering on Mac. Haven't had an issue of stuff breaking. It should work with any 1.5 model that uses the 1.5 v1 inference config because that's what I default to. I'll add an option to edit these settings later.

But this PR is slightly on hold because I'm working on some other stuff at the moment.

blessedcoolant avatar Dec 12 '22 14:12 blessedcoolant

At one point @ebr expressed interest in writing a model scanner to incorporate into the configure_invokeai.py script. Is that still needed?

On Mon, Dec 12, 2022 at 9:55 AM blessedcoolant @.***> wrote:

ahh I see. yeah.. If you want autocomplete, could be worth having the backend of the app scan the directory structure of the relevant directories/docker volume mounts, defaulting to the directory where the models are stored in.

Yep. That would limit the user to storing models in a single folder we specify. Trying to explore options where a user would be able to pick any the want. But we're also gonna revamp the way model handling is done in general so a user can submit folders and all of them would just get scanned.

By the way, what models have you imported successfully with this code?

All of them? I haven't had any problems on Windows. But I know there's some issues of the tkinter window lingering on Mac. Haven't had an issue of stuff breaking. It should work with any 1.5 model that uses the 1.5 v1 inference config because that's what I default to. I'll add an option to edit these settings later.

But this PR is slightly on hold because I'm working on some other stuff at the moment.

— Reply to this email directly, view it on GitHub https://github.com/invoke-ai/InvokeAI/pull/1656#issuecomment-1346644826, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA3EVP7W7PQLKNPNWBB65LWM44E5ANCNFSM6AAAAAASQRCJJI . You are receiving this because you commented.Message ID: @.***>

--

Lincoln Stein

Head, Adaptive Oncology, OICR

Senior Principal Investigator, OICR

Professor, Department of Molecular Genetics, University of Toronto

Tel: 416-673-8514

Cell: 416-817-8240

@.***

E**xecutive Assistant

Michelle Xin

Tel: 647-260-7927

@.*** @.**>

Ontario Institute for Cancer Research

MaRS Centre, 661 University Avenue, Suite 510, Toronto, Ontario, Canada M5G 0A3

@OICR_news https://can01.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftwitter.com%2Foicr_news&data=04%7C01%7CMichelle.Xin%40oicr.on.ca%7C9fa8636ff38b4a60ff5a08d926dd2113%7C9df949f8a6eb419d9caa1f8c83db674f%7C0%7C0%7C637583553462287559%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=PS9KzggzFoecbbt%2BZQyhkWkQo9D0hHiiujsbP7Idv4s%3D&reserved=0 | www.oicr.on.ca

Collaborate. Translate. Change lives.

This message and any attachments may contain confidential and/or privileged information for the sole use of the intended recipient. Any review or distribution by anyone other than the person for whom it was originally intended is strictly prohibited. If you have received this message in error, please contact the sender and delete all copies. Opinions, conclusions or other information contained in this message may not be that of the organization.

lstein avatar Dec 12 '22 15:12 lstein

@lstein I've already coded that in this PR. The trick is to have the frontend allow a user to pick this folder.

The issue arises ... because of security reasons, browser based JS does not have access to the filesystem meaning it can never return the abs path.

So as a bypass, I made tkinter (python's GUI) load up to pick this for the user. But this has its own set of complications.

  1. tkinter functionality with MacOS is a bit finicky (but I'm sure this can be fixed with some research)
  2. Because we are invoking tkinter to do the file dialog, this means stuff like docker images and etc might not be privy to making this happen.

The alternative is to let the user manually fill out URLs that we send to the backend and scan. This removes the file dialog functionality but might not be too bad for the UX. And if we go this route we'll need to implement the feature to store these folders somewhere in the config file. Because I don't want to save them in the browsers localStorage. Wiping that should not wipe the user setting for this. So maybe @ebr could work on the functionality on this.

blessedcoolant avatar Dec 12 '22 15:12 blessedcoolant

Continued in #2127

blessedcoolant avatar Dec 24 '22 20:12 blessedcoolant