Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,8 @@ import torch
|
|
| 3 |
from diffusers import StableDiffusionXLPipeline, AutoencoderKL
|
| 4 |
from huggingface_hub import hf_hub_download
|
| 5 |
from safetensors.torch import load_file
|
|
|
|
|
|
|
| 6 |
import lora
|
| 7 |
import copy
|
| 8 |
import json
|
|
@@ -32,7 +34,7 @@ with open("sdxl_loras.json", "r") as file:
|
|
| 32 |
for item in data
|
| 33 |
]
|
| 34 |
|
| 35 |
-
device = "cuda"
|
| 36 |
|
| 37 |
state_dicts = {}
|
| 38 |
|
|
@@ -98,7 +100,6 @@ def update_selection(selected_state: gr.SelectData, sdxl_loras):
|
|
| 98 |
use_with_diffusers += f"This LoRA is not compatible with diffusers natively yet. But you can still use it on diffusers with sdxl-cog `TokenEmbeddingsHandler` class, check out the [model repo](https://huggingface.co/{lora_repo}#inference-with-🧨-diffusers)"
|
| 99 |
use_with_uis = f'''
|
| 100 |
## Use it with Comfy UI, Invoke AI, SD.Next, AUTO1111:
|
| 101 |
-
|
| 102 |
### Download the `*.safetensors` weights of [here](https://huggingface.co/{lora_repo}/resolve/main/{weight_name})
|
| 103 |
|
| 104 |
- [ComfyUI guide](https://comfyanonymous.github.io/ComfyUI_examples/lora/)
|
|
@@ -245,9 +246,9 @@ with gr.Blocks(css="custom.css") as demo:
|
|
| 245 |
prompt = gr.Textbox(label="Prompt", show_label=False, lines=1, max_lines=1, placeholder="Type a prompt after selecting a LoRA", elem_id="prompt")
|
| 246 |
button = gr.Button("Run", elem_id="run_button")
|
| 247 |
with gr.Group(elem_id="share-btn-container", visible=False) as share_group:
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
result = gr.Image(
|
| 252 |
interactive=False, label="Generated Image", elem_id="result-image"
|
| 253 |
)
|
|
@@ -313,7 +314,7 @@ with gr.Blocks(css="custom.css") as demo:
|
|
| 313 |
).success(
|
| 314 |
fn=run_lora,
|
| 315 |
inputs=[prompt, negative, weight, selected_state, gr_sdxl_loras],
|
| 316 |
-
outputs=[result],
|
| 317 |
)
|
| 318 |
button.click(
|
| 319 |
fn=check_selected,
|
|
@@ -323,9 +324,9 @@ with gr.Blocks(css="custom.css") as demo:
|
|
| 323 |
).success(
|
| 324 |
fn=run_lora,
|
| 325 |
inputs=[prompt, negative, weight, selected_state, gr_sdxl_loras],
|
| 326 |
-
outputs=[result],
|
| 327 |
)
|
| 328 |
-
|
| 329 |
demo.load(fn=shuffle_gallery, inputs=[gr_sdxl_loras], outputs=[gallery, gr_sdxl_loras], queue=False)
|
| 330 |
demo.queue(max_size=20)
|
| 331 |
demo.launch(debug=True, auth=custom_auth)
|
|
|
|
| 3 |
from diffusers import StableDiffusionXLPipeline, AutoencoderKL
|
| 4 |
from huggingface_hub import hf_hub_download
|
| 5 |
from safetensors.torch import load_file
|
| 6 |
+
from share_btn import community_icon_html, loading_icon_html, share_js
|
| 7 |
+
from cog_sdxl_dataset_and_utils import TokenEmbeddingsHandler
|
| 8 |
import lora
|
| 9 |
import copy
|
| 10 |
import json
|
|
|
|
| 34 |
for item in data
|
| 35 |
]
|
| 36 |
|
| 37 |
+
device = "cuda"
|
| 38 |
|
| 39 |
state_dicts = {}
|
| 40 |
|
|
|
|
| 100 |
use_with_diffusers += f"This LoRA is not compatible with diffusers natively yet. But you can still use it on diffusers with sdxl-cog `TokenEmbeddingsHandler` class, check out the [model repo](https://huggingface.co/{lora_repo}#inference-with-🧨-diffusers)"
|
| 101 |
use_with_uis = f'''
|
| 102 |
## Use it with Comfy UI, Invoke AI, SD.Next, AUTO1111:
|
|
|
|
| 103 |
### Download the `*.safetensors` weights of [here](https://huggingface.co/{lora_repo}/resolve/main/{weight_name})
|
| 104 |
|
| 105 |
- [ComfyUI guide](https://comfyanonymous.github.io/ComfyUI_examples/lora/)
|
|
|
|
| 246 |
prompt = gr.Textbox(label="Prompt", show_label=False, lines=1, max_lines=1, placeholder="Type a prompt after selecting a LoRA", elem_id="prompt")
|
| 247 |
button = gr.Button("Run", elem_id="run_button")
|
| 248 |
with gr.Group(elem_id="share-btn-container", visible=False) as share_group:
|
| 249 |
+
community_icon = gr.HTML(community_icon_html)
|
| 250 |
+
loading_icon = gr.HTML(loading_icon_html)
|
| 251 |
+
share_button = gr.Button("Share to community", elem_id="share-btn")
|
| 252 |
result = gr.Image(
|
| 253 |
interactive=False, label="Generated Image", elem_id="result-image"
|
| 254 |
)
|
|
|
|
| 314 |
).success(
|
| 315 |
fn=run_lora,
|
| 316 |
inputs=[prompt, negative, weight, selected_state, gr_sdxl_loras],
|
| 317 |
+
outputs=[result, share_group],
|
| 318 |
)
|
| 319 |
button.click(
|
| 320 |
fn=check_selected,
|
|
|
|
| 324 |
).success(
|
| 325 |
fn=run_lora,
|
| 326 |
inputs=[prompt, negative, weight, selected_state, gr_sdxl_loras],
|
| 327 |
+
outputs=[result, share_group],
|
| 328 |
)
|
| 329 |
+
share_button.click(None, [], [], _js=share_js)
|
| 330 |
demo.load(fn=shuffle_gallery, inputs=[gr_sdxl_loras], outputs=[gallery, gr_sdxl_loras], queue=False)
|
| 331 |
demo.queue(max_size=20)
|
| 332 |
demo.launch(debug=True, auth=custom_auth)
|