multimodalart HF staff commited on
Commit
9ab148b
1 Parent(s): 530d282

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -18
app.py CHANGED
@@ -49,26 +49,33 @@ def update_selection(selected_state: gr.SelectData):
49
  new_placeholder = "Type a prompt! This style works for all prompts without a trigger word" if instance_prompt == "" else "Type a prompt to use your selected LoRA"
50
  weight_name = sdxl_loras[selected_state.index]["weights"]
51
  updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✨"
52
- use_with_diffusers = f'''
53
  ## Using [`{lora_repo}`](https://huggingface.co/{lora_repo})
54
-
55
- ## Use it with diffusers:
56
-
57
- ```python
58
- from diffusers import StableDiffusionXLPipeline
59
- import torch
60
-
61
- model_path = "stabilityai/stable-diffusion-xl-base-1.0"
62
- pipe = StableDiffusionPipeline.from_pretrained(model_path, torch_dtype=torch.float16)
63
- pipe.to("cuda")
64
- pipe.load_lora_weights("{lora_repo}", weight_name={weight_name})
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
- prompt = "{instance_prompt}..."
67
- lora_weight = 0.5
68
- image = pipe(prompt, num_inference_steps=30, guidance_scale=7.5, cross_attention_kwargs={{"scale":lora_weight}}).images[0]
69
- image.save("image.png")
70
- ```
71
- '''
72
  use_with_uis = f'''
73
  ## Use it with Comfy UI, Invoke AI, SD.Next, AUTO1111:
74
 
 
49
  new_placeholder = "Type a prompt! This style works for all prompts without a trigger word" if instance_prompt == "" else "Type a prompt to use your selected LoRA"
50
  weight_name = sdxl_loras[selected_state.index]["weights"]
51
  updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✨"
52
+ use_with_diffusers = f"""
53
  ## Using [`{lora_repo}`](https://huggingface.co/{lora_repo})
54
+
55
+ ## Use it with diffusers:
56
+ """
57
+ if is_compatible:
58
+ use_with_diffusers += f'''
59
+ ```python
60
+ from diffusers import StableDiffusionXLPipeline
61
+ import torch
62
+
63
+ model_path = "stabilityai/stable-diffusion-xl-base-1.0"
64
+ pipe = StableDiffusionPipeline.from_pretrained(model_path, torch_dtype=torch.float16)
65
+ pipe.to("cuda")
66
+ pipe.load_lora_weights("{lora_repo}", weight_name="{weight_name}")
67
+
68
+ prompt = "{instance_prompt}..."
69
+ lora_weight = 0.5
70
+ image = pipe(prompt, num_inference_steps=30, guidance_scale=7.5, cross_attention_kwargs={{"scale": lora_weight}}).images[0]
71
+ image.save("image.png")
72
+ ```
73
+ '''
74
+ else:
75
+ use_with_diffusers += '''
76
+ This LoRA is not compatible with diffusers natively yet. But you can still use it on diffusers with `bmaltais/kohya_ss` LoRA class, check out this [Google Colab](https://colab.research.google.com/drive/14aEJsKdEQ9_kyfsiV6JDok799kxPul0j )
77
+ '''
78
 
 
 
 
 
 
 
79
  use_with_uis = f'''
80
  ## Use it with Comfy UI, Invoke AI, SD.Next, AUTO1111:
81