Spaces:
Build error
Build error
controlnet lora sd15: add activation token
Browse files
frontend/src/lib/components/PipelineOptions.svelte
CHANGED
|
@@ -15,7 +15,7 @@
|
|
| 15 |
$: featuredOptions = pipelineParams?.filter((e) => e?.hide !== true);
|
| 16 |
</script>
|
| 17 |
|
| 18 |
-
<div>
|
| 19 |
{#if featuredOptions}
|
| 20 |
{#each featuredOptions as params}
|
| 21 |
{#if params.field === FieldType.RANGE}
|
|
|
|
| 15 |
$: featuredOptions = pipelineParams?.filter((e) => e?.hide !== true);
|
| 16 |
</script>
|
| 17 |
|
| 18 |
+
<div class="grid grid-cols-1 items-center gap-3">
|
| 19 |
{#if featuredOptions}
|
| 20 |
{#each featuredOptions as params}
|
| 21 |
{#if params.field === FieldType.RANGE}
|
pipelines/controlnetLoraSD15.py
CHANGED
|
@@ -19,11 +19,12 @@ from PIL import Image
|
|
| 19 |
|
| 20 |
taesd_model = "madebyollin/taesd"
|
| 21 |
controlnet_model = "lllyasviel/control_v11p_sd15_canny"
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
"
|
| 25 |
-
"nitrosocke/
|
| 26 |
-
|
|
|
|
| 27 |
lcm_lora_id = "latent-consistency/lcm-lora-sdv1-5"
|
| 28 |
|
| 29 |
|
|
@@ -46,8 +47,8 @@ class Pipeline:
|
|
| 46 |
)
|
| 47 |
model_id: str = Field(
|
| 48 |
"plasmo/woolitize",
|
| 49 |
-
title="Base
|
| 50 |
-
values=base_models,
|
| 51 |
field="select",
|
| 52 |
id="model_id",
|
| 53 |
)
|
|
@@ -149,14 +150,14 @@ class Pipeline:
|
|
| 149 |
self.pipes = {}
|
| 150 |
|
| 151 |
if args.safety_checker:
|
| 152 |
-
for model_id in base_models:
|
| 153 |
pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
|
| 154 |
model_id,
|
| 155 |
controlnet=controlnet_canny,
|
| 156 |
)
|
| 157 |
self.pipes[model_id] = pipe
|
| 158 |
else:
|
| 159 |
-
for model_id in base_models:
|
| 160 |
pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
|
| 161 |
model_id,
|
| 162 |
safety_checker=None,
|
|
@@ -199,7 +200,9 @@ class Pipeline:
|
|
| 199 |
print(f"Using model: {params.model_id}")
|
| 200 |
pipe = self.pipes[params.model_id]
|
| 201 |
|
| 202 |
-
|
|
|
|
|
|
|
| 203 |
control_image = self.canny_torch(
|
| 204 |
params.image, params.canny_low_threshold, params.canny_high_threshold
|
| 205 |
)
|
|
|
|
| 19 |
|
| 20 |
taesd_model = "madebyollin/taesd"
|
| 21 |
controlnet_model = "lllyasviel/control_v11p_sd15_canny"
|
| 22 |
+
# base model with activation token, it will prepend the prompt with the activation token
|
| 23 |
+
base_models = {
|
| 24 |
+
"plasmo/woolitize": "woolitize",
|
| 25 |
+
"nitrosocke/Ghibli-Diffusion": "ghibli style",
|
| 26 |
+
"nitrosocke/mo-di-diffusion": "modern disney style",
|
| 27 |
+
}
|
| 28 |
lcm_lora_id = "latent-consistency/lcm-lora-sdv1-5"
|
| 29 |
|
| 30 |
|
|
|
|
| 47 |
)
|
| 48 |
model_id: str = Field(
|
| 49 |
"plasmo/woolitize",
|
| 50 |
+
title="Base Model",
|
| 51 |
+
values=list(base_models.keys()),
|
| 52 |
field="select",
|
| 53 |
id="model_id",
|
| 54 |
)
|
|
|
|
| 150 |
self.pipes = {}
|
| 151 |
|
| 152 |
if args.safety_checker:
|
| 153 |
+
for model_id in base_models.keys():
|
| 154 |
pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
|
| 155 |
model_id,
|
| 156 |
controlnet=controlnet_canny,
|
| 157 |
)
|
| 158 |
self.pipes[model_id] = pipe
|
| 159 |
else:
|
| 160 |
+
for model_id in base_models.keys():
|
| 161 |
pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
|
| 162 |
model_id,
|
| 163 |
safety_checker=None,
|
|
|
|
| 200 |
print(f"Using model: {params.model_id}")
|
| 201 |
pipe = self.pipes[params.model_id]
|
| 202 |
|
| 203 |
+
activation_token = base_models[params.model_id]
|
| 204 |
+
prompt = f"{activation_token} {params.prompt}"
|
| 205 |
+
prompt_embeds = pipe.compel_proc(prompt)
|
| 206 |
control_image = self.canny_torch(
|
| 207 |
params.image, params.canny_low_threshold, params.canny_high_threshold
|
| 208 |
)
|