Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,8 @@ from peft import PeftModel, LoraConfig
|
|
| 6 |
import os
|
| 7 |
|
| 8 |
def get_lora_sd_pipeline(
|
| 9 |
-
ckpt_dir='./lora_logos',
|
|
|
|
| 10 |
base_model_name_or_path=None,
|
| 11 |
dtype=torch.float16,
|
| 12 |
adapter_name="default"
|
|
@@ -53,10 +54,13 @@ def align_embeddings(prompt_embeds, negative_prompt_embeds):
|
|
| 53 |
torch.nn.functional.pad(negative_prompt_embeds, (0, 0, 0, max_length - negative_prompt_embeds.shape[1]))
|
| 54 |
|
| 55 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 56 |
-
model_id_default = "CompVis/stable-diffusion-v1-4"
|
|
|
|
| 57 |
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
| 58 |
|
| 59 |
-
pipe_default = get_lora_sd_pipeline(ckpt_dir='./lora_logos', base_model_name_or_path=model_id_default, dtype=torch_dtype).to(device)
|
|
|
|
|
|
|
| 60 |
|
| 61 |
MAX_SEED = np.iinfo(np.int32).max
|
| 62 |
MAX_IMAGE_SIZE = 1024
|
|
@@ -67,7 +71,8 @@ def infer(
|
|
| 67 |
width=512,
|
| 68 |
height=512,
|
| 69 |
num_inference_steps=20,
|
| 70 |
-
model_id='CompVis/stable-diffusion-v1-4',
|
|
|
|
| 71 |
seed=42,
|
| 72 |
guidance_scale=7.0,
|
| 73 |
lora_scale=0.5,
|
|
@@ -117,7 +122,8 @@ with gr.Blocks(css=css) as demo:
|
|
| 117 |
model_id = gr.Textbox(
|
| 118 |
label="Model ID",
|
| 119 |
max_lines=1,
|
| 120 |
-
placeholder="Enter model id like 'CompVis/stable-diffusion-v1-4'",
|
|
|
|
| 121 |
value=model_id_default
|
| 122 |
)
|
| 123 |
|
|
|
|
| 6 |
import os
|
| 7 |
|
| 8 |
def get_lora_sd_pipeline(
|
| 9 |
+
#ckpt_dir='./lora_logos',
|
| 10 |
+
ckpt_dir='./lora_man_animestyle',
|
| 11 |
base_model_name_or_path=None,
|
| 12 |
dtype=torch.float16,
|
| 13 |
adapter_name="default"
|
|
|
|
| 54 |
torch.nn.functional.pad(negative_prompt_embeds, (0, 0, 0, max_length - negative_prompt_embeds.shape[1]))
|
| 55 |
|
| 56 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 57 |
+
#model_id_default = "CompVis/stable-diffusion-v1-4"
|
| 58 |
+
model_id_default = "stable-diffusion-v1-5/stable-diffusion-v1-5"
|
| 59 |
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
| 60 |
|
| 61 |
+
#pipe_default = get_lora_sd_pipeline(ckpt_dir='./lora_logos', base_model_name_or_path=model_id_default, dtype=torch_dtype).to(device)
|
| 62 |
+
pipe_default = get_lora_sd_pipeline(ckpt_dir='./lora_man_animestyle', base_model_name_or_path=model_id_default, dtype=torch_dtype).to(device)
|
| 63 |
+
|
| 64 |
|
| 65 |
MAX_SEED = np.iinfo(np.int32).max
|
| 66 |
MAX_IMAGE_SIZE = 1024
|
|
|
|
| 71 |
width=512,
|
| 72 |
height=512,
|
| 73 |
num_inference_steps=20,
|
| 74 |
+
#model_id='CompVis/stable-diffusion-v1-4',
|
| 75 |
+
model_id='stable-diffusion-v1-5/stable-diffusion-v1-5',
|
| 76 |
seed=42,
|
| 77 |
guidance_scale=7.0,
|
| 78 |
lora_scale=0.5,
|
|
|
|
| 122 |
model_id = gr.Textbox(
|
| 123 |
label="Model ID",
|
| 124 |
max_lines=1,
|
| 125 |
+
#placeholder="Enter model id like 'CompVis/stable-diffusion-v1-4'",
|
| 126 |
+
placeholder="Enter model id like 'stable-diffusion-v1-5/stable-diffusion-v1-5'",
|
| 127 |
value=model_id_default
|
| 128 |
)
|
| 129 |
|