New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added hf models import tab and route for getting available hf models #5891
Conversation
.../features/modelManagerV2/subpanels/AddModelPanel/HuggingFaceFolder/HuggingFaceResultItem.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should change any model install files, or select_hf_files.py
. That's all fairly sensitive logic.
Calling HuggingFaceMetadata.download_urls()
does filtering to figure out which URLs it needs to download for diffusers-format models, but for this feature, we want to list all files in the repo.
HuggingFaceMetadata.files
will have all files, and we can show that in the UI. Then I think we want to offer two options.
- Install this whole HF repo as a single diffusers model.
We can check for the presence of a model_index.json
file, which indicates the repo is a diffusers format model. If that exists, we can hint to install as diffusers.
If the user chooses this option, we'd hit the /install
route with the repo id to initiate the download.
We could also offer a choice of repo variant - probably FP16, FP32 and a default (None). I don't think the other values are actually support by invoke. I'm not sure if this is necessary though.
- Install a specific checkpoint file from within the repo.
We'd suggest this if there is no mode_index.json
file. In this case, users would select an individual file to install as a checkpoint model file.
In this case, we hit the /install
route with the .url
of the file - e.g. HuggingFaceMetadata.files[selectedFileIndex].url
.
...ontend/web/src/features/modelManagerV2/subpanels/AddModelPanel/ScanFolder/ScanFolderForm.tsx
Show resolved
Hide resolved
...src/features/modelManagerV2/subpanels/AddModelPanel/HuggingFaceFolder/HuggingFaceResults.tsx
Show resolved
Hide resolved
...src/features/modelManagerV2/subpanels/AddModelPanel/HuggingFaceFolder/HuggingFaceResults.tsx
Show resolved
Hide resolved
...src/features/modelManagerV2/subpanels/AddModelPanel/HuggingFaceFolder/HuggingFaceResults.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worked well for me!
...eb/src/features/modelManagerV2/subpanels/AddModelPanel/HuggingFaceFolder/HuggingFaceForm.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are doing just a bit too much on the frontend by letting it decide what kind of models are available in the HF api response.
Suggest extending HuggingFaceMetadata
with is_diffusers
and ckpt_urls
:
class HuggingFaceMetadata(ModelMetadataWithFiles):
"""Extended metadata fields provided by HuggingFace."""
type: Literal["huggingface"] = "huggingface"
id: str = Field(description="The HF model id")
api_response: Optional[str] = Field(description="Response from the HF API as stringified JSON", default=None)
is_diffusers: bool = Field(description="Whether the metadata is for a Diffusers format model")
ckpt_urls: Optional[List[AnyHttpUrl]] = Field(
description="URLs for all checkpoint format models in the metadata", default=None
)
Then, in HuggingFaceMetadataFetch
, figure these attrs out:
class HuggingFaceMetadataFetch(ModelMetadataFetchBase):
...
def from_id(self, id: str, variant: Optional[ModelRepoVariant] = None) -> AnyModelRepoMetadata:
...
# diffusers models have a `model_index.json` file
is_diffusers = any(str(f.url).endswith("model_index.json") for f in files)
# These URLs will be exposed to the user - I think these are the only file types we fully support
ckpt_urls = (
None
if is_diffusers
else [
f.url
for f in files
if str(f.url).endswith(
(
".safetensors",
".bin",
".pth",
".pt",
".ckpt",
)
)
]
)
return HuggingFaceMetadata(
id=model_info.id,
name=name,
files=files,
api_response=json.dumps(model_info.__dict__, default=str),
is_diffusers=is_diffusers,
ckpt_urls=ckpt_urls,
)
The UI can then also more easily handle the case where a repo ID is provided that has no models in it.
...eb/src/features/modelManagerV2/subpanels/AddModelPanel/HuggingFaceFolder/HuggingFaceForm.tsx
Outdated
Show resolved
Hide resolved
Rebase failed
…o not mess with existing model install
…FaceMetadata, removed logic from service
d9d999e
to
366e6d9
Compare
Thanks @chainchompa ! I did a styling pass and updated some of the verbiage. Screen.Recording.2024-03-13.at.8.54.58.pm.movThere appears to be some jank in the Tab components that causes weird overflow, which you had worked through using margins. I fiddled around and found adding |
What type of PR is this? (check all applicable)
Have you discussed this change with the InvokeAI team?
Have you updated all relevant documentation?
Description
Related Tickets & Documents
QA Instructions, Screenshots, Recordings
Merge Plan
Added/updated tests?
have not been included
[optional] Are there any post deployment tasks we need to perform?