Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -38,7 +38,8 @@ def get_lora_sd_pipeline(
|
|
38 |
|
39 |
pipe = StableDiffusionPipeline.from_pretrained(base_model_name_or_path, torch_dtype=dtype).to(device)
|
40 |
pipe.unet = PeftModel.from_pretrained(pipe.unet, unet_sub_dir, adapter_name=adapter_name)
|
41 |
-
pipe.unet.set_adapter(adapter_name
|
|
|
42 |
|
43 |
if os.path.exists(text_encoder_sub_dir):
|
44 |
pipe.text_encoder = PeftModel.from_pretrained(
|
@@ -77,9 +78,6 @@ def encode_prompt(prompt, tokenizer, text_encoder):
|
|
77 |
return prompt_embeds
|
78 |
|
79 |
|
80 |
-
pipe = get_lora_sd_pipeline(adapter_name="sticker_of_funny_cat_Pusheen")
|
81 |
-
|
82 |
-
|
83 |
# @spaces.GPU #[uncomment to use ZeroGPU]
|
84 |
def infer(
|
85 |
prompt,
|
@@ -100,7 +98,6 @@ def infer(
|
|
100 |
pipe = pipe.to(device)
|
101 |
prompt_embeds = encode_prompt(prompt, pipe.tokenizer, pipe.text_encoder)
|
102 |
negative_prompt_embeds = encode_prompt(negative_prompt, pipe.tokenizer, pipe.text_encoder)
|
103 |
-
# pipe.fuse_lora(lora_scale=lora_scale)
|
104 |
|
105 |
image = pipe(
|
106 |
prompt_embeds=prompt_embeds,
|
|
|
38 |
|
39 |
pipe = StableDiffusionPipeline.from_pretrained(base_model_name_or_path, torch_dtype=dtype).to(device)
|
40 |
pipe.unet = PeftModel.from_pretrained(pipe.unet, unet_sub_dir, adapter_name=adapter_name)
|
41 |
+
pipe.unet.set_adapter(adapter_name)
|
42 |
+
pipe.fuse_lora(lora_scale=lora_scale)
|
43 |
|
44 |
if os.path.exists(text_encoder_sub_dir):
|
45 |
pipe.text_encoder = PeftModel.from_pretrained(
|
|
|
78 |
return prompt_embeds
|
79 |
|
80 |
|
|
|
|
|
|
|
81 |
# @spaces.GPU #[uncomment to use ZeroGPU]
|
82 |
def infer(
|
83 |
prompt,
|
|
|
98 |
pipe = pipe.to(device)
|
99 |
prompt_embeds = encode_prompt(prompt, pipe.tokenizer, pipe.text_encoder)
|
100 |
negative_prompt_embeds = encode_prompt(negative_prompt, pipe.tokenizer, pipe.text_encoder)
|
|
|
101 |
|
102 |
image = pipe(
|
103 |
prompt_embeds=prompt_embeds,
|