Skip to content
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

[community] Load Models from Sources like Civitai into Existing Pipelines #9986

Merged
merged 38 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
8924b57
Added example of model search.
suzukimain Nov 21, 2024
3e158b3
Combine processing into one file
suzukimain Nov 21, 2024
ca50857
Add parameters for base model
suzukimain Nov 21, 2024
28352b0
Bug Fixes
suzukimain Nov 21, 2024
76b32da
bug fix
suzukimain Nov 21, 2024
17e38b0
Create README.md
suzukimain Nov 21, 2024
aac8073
Update search_for_civitai_and_HF.py
suzukimain Nov 21, 2024
6c3c259
Create requirements.txt
suzukimain Nov 21, 2024
61aa2aa
Merge branch 'huggingface:main' into ModelSearch
suzukimain Nov 21, 2024
5202bb1
bug fix
suzukimain Nov 21, 2024
13a66bb
Update README.md
suzukimain Nov 21, 2024
920876d
bug fix
suzukimain Nov 21, 2024
d953d7f
Correction of typos
suzukimain Nov 21, 2024
36d34a6
Merge branch 'main' into ModelSearch
suzukimain Nov 22, 2024
4b02904
Update examples/model_search/README.md
suzukimain Dec 3, 2024
994fe95
Update examples/model_search/README.md
suzukimain Dec 3, 2024
65372d4
Update examples/model_search/README.md
suzukimain Dec 3, 2024
ab76aa4
Update examples/model_search/README.md
suzukimain Dec 3, 2024
341f3a3
Update examples/model_search/README.md
suzukimain Dec 3, 2024
05594cc
Update examples/model_search/README.md
suzukimain Dec 3, 2024
241c943
apply the changes
suzukimain Dec 4, 2024
43d936a
Replace search_for_civitai_and_HF.py with pipeline_easy.py
suzukimain Dec 4, 2024
745d4d0
Merge branch 'main' into ModelSearch
suzukimain Dec 4, 2024
4f3d4b0
Update examples/model_search/README.md
suzukimain Dec 4, 2024
8b2e3e6
Update examples/model_search/README.md
suzukimain Dec 4, 2024
2e32020
Update examples/model_search/README.md
suzukimain Dec 4, 2024
68000fa
Update README.md
suzukimain Dec 4, 2024
cd70647
Organize the table of parameters
suzukimain Dec 4, 2024
c9e87b8
Update README.md
suzukimain Dec 4, 2024
b10a55a
Update README.md
suzukimain Dec 4, 2024
c3e51e6
Merge branch 'main' into ModelSearch
suzukimain Dec 4, 2024
026202c
Update README.md
suzukimain Dec 5, 2024
ac1c3e1
Merge branch 'huggingface:main' into ModelSearch
suzukimain Dec 6, 2024
efe5fba
make style
suzukimain Dec 6, 2024
5df8f99
Fixing the style of pipeline
suzukimain Dec 6, 2024
4ff6e38
Fix pipeline style
suzukimain Dec 6, 2024
5e92b8e
fix
suzukimain Dec 6, 2024
54fd90e
Merge branch 'main' into ModelSearch
suzukimain Dec 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions examples/model_search/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Searching Models on Civitai and Hugging Face
Please refer to the original library [here](https://pypi.org/project/auto-diffusers/)
suzukimain marked this conversation as resolved.
Show resolved Hide resolved

## Installing the dependencies

Before running the scripts, make sure to install the library's training dependencies:

**Important**

To make sure you can successfully run the latest versions of the example scripts, we highly recommend **installing from source** and keeping the install up to date as we update the example scripts frequently and install some example-specific requirements. To do this, execute the following steps in a new virtual environment:
```bash
git clone https://github.com/huggingface/diffusers
cd diffusers
pip install .
suzukimain marked this conversation as resolved.
Show resolved Hide resolved
```

Then cd in the example folder and run:
```bash
pip install -r requirements.txt
```


suzukimain marked this conversation as resolved.
Show resolved Hide resolved
## Example<a name = "Example"></a>
suzukimain marked this conversation as resolved.
Show resolved Hide resolved
```bash
!wget https://raw.githubusercontent.com/suzukimain/diffusers/refs/heads/ModelSearch/examples/model_search/search_for_civitai_and_HF.py
```

```python
# Search for Civitai

from search_for_civitai_and_HF import CivitaiSearchPipeline
from diffusers import StableDiffusionPipeline


model_path = CivitaiSearchPipeline.for_civitai(
"any",
suzukimain marked this conversation as resolved.
Show resolved Hide resolved
base_model="SD 1.5",
download=True
)
pipe = StableDiffusionPipeline.from_single_file(model_path).to("cuda")

```


```python
# Search for Hugging Face

from search_for_civitai_and_HF import HFSearchPipeline
from diffusers import StableDiffusionPipeline

model_path = HFSearchPipeline.for_HF(
"stable",
checkpoint_format="diffusers",
download = False
)

pipe = StableDiffusionPipeline.from_pretrained(model_path).to("cuda")

# or

model_path = HFSearchPipeline.for_HF(
"stable",
checkpoint_format="single_file",
download = False
)

pipe = StableDIffusionPipeline.from_single_file(model_path).to("cuda")
```

<a id="Details"></a>
<details close>
suzukimain marked this conversation as resolved.
Show resolved Hide resolved

> Arguments of `HFSearchPipeline.for_HF`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> Arguments of `HFSearchPipeline.for_HF`
### HFSearchPipeline.for_HF parameters

>
suzukimain marked this conversation as resolved.
Show resolved Hide resolved
| Name | Type | Default | Description |
|:----------------:|:-------:|:-------------:|:-------------------------------------------------------------:|
| search_word | string | ー | The search query string. |
| revision | string | None | The specific version of the model to download. |
| checkpoint_format| string | "single_file" | The format of the model checkpoint. |
| download | bool | False | Whether to download the model. |
| force_download | bool | False | Whether to force the download if the model already exists. |
| include_params | bool | False | Whether to include parameters in the returned data. |
| pipeline_tag | string | None | Tag to filter models by pipeline. |
| hf_token | string | None | API token for Hugging Face authentication. |
| skip_error | bool | False | Whether to skip errors and return None. |



> Arguments of `CivitaiSearchPipeline.for_civitai`
>
suzukimain marked this conversation as resolved.
Show resolved Hide resolved
| Name | Type | Default | Description |
|:----------------:|:-------:|:-------------:|:-------------------------------------------------------------:|
| search_word | string | ー | The search query string. |
| model_type | string | "Checkpoint" | The type of model to search for. |
| base_model | string | None | The base model to filter by. |
| download | bool | False | Whether to download the model. |
| force_download | bool | False | Whether to force the download if the model already exists. |
| civitai_token | string | None | API token for Civitai authentication. |
| include_params | bool | False | Whether to include parameters in the returned data. |
| skip_error | bool | False | Whether to skip errors and return None. |



<a id="search-word"></a>
<details open>
<summary>search_word</summary>

| Type | Description |
| :--------------------------: | :--------------------------------------------------------------------: |
| keyword | Keywords to search model<br> |
| url | URL of either huggingface or Civitai |
| Local directory or file path | Locally stored model paths |
| huggingface path | The following format: `< creator > / < repo >` |
suzukimain marked this conversation as resolved.
Show resolved Hide resolved

</details>


<a id="model_type"></a>
<details open>
<summary>model_type</summary>

| Input Available |
| :--------------------------: |
| `Checkpoint` |
| `TextualInversion` |
| `Hypernetwork` |
| `AestheticGradient` |
| `LORA` |
| `Controlnet` |
| `Poses` |

</details>
suzukimain marked this conversation as resolved.
Show resolved Hide resolved


<a id="checkpoint_format"></a>
<details open>
<summary>checkpoint_format</summary>

| Argument | Description |
| :--------------------------: | :--------------------------------------------------------------------: |
| all | The `multifolder diffusers format checkpoint` takes precedence. |
| single_file | Only `single file checkpoint` are searched. |
| diffusers | Search only for `multifolder diffusers format checkpoint` |
suzukimain marked this conversation as resolved.
Show resolved Hide resolved

</details>

</details>
1 change: 1 addition & 0 deletions examples/model_search/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
huggingface-hub>=0.26.2
Loading