Skip to content

Commit 66535f5

Browse files
authored
Improve prompting for diffusers default snippets
Addressing comments left on #907, specially for LoRAs
1 parent bbe2ae8 commit 66535f5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/tasks/src/model-libraries-snippets.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ function get_base_diffusers_model(model: ModelData): string {
7070
return model.cardData?.base_model?.toString() ?? "fill-in-base-model";
7171
}
7272

73+
function get_prompt_from_diffusers_model(model: ModelData): string {
74+
return model.cardData?.widget?.[0]?.text?.toString()
75+
?? model.cardData?.instance_prompt?.toString()
76+
?? "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k";
77+
}
78+
7379
export const bertopic = (model: ModelData): string[] => [
7480
`from bertopic import BERTopic
7581
@@ -134,7 +140,7 @@ const diffusers_default = (model: ModelData) => [
134140
135141
pipe = DiffusionPipeline.from_pretrained("${model.id}")
136142
137-
prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
143+
prompt = "${get_prompt_from_diffusers_model(model)}"
138144
image = pipe(prompt).images[0]`,
139145
];
140146

@@ -153,7 +159,7 @@ const diffusers_lora = (model: ModelData) => [
153159
pipe = DiffusionPipeline.from_pretrained("${get_base_diffusers_model(model)}")
154160
pipe.load_lora_weights("${model.id}")
155161
156-
prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
162+
prompt = "${get_prompt_from_diffusers_model(model)}"
157163
image = pipe(prompt).images[0]`,
158164
];
159165

0 commit comments

Comments
 (0)