multimodalart HF staff commited on
Commit
53b0d0a
1 Parent(s): 7950bc5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -134,7 +134,14 @@ def create_readme(info, downloaded_files, user_repo_id, link_civit=False, is_aut
134
 
135
  trained_words = info['trainedWords'] if 'trainedWords' in info and info['trainedWords'] else []
136
  formatted_words = ', '.join(f'`{word}`' for word in trained_words)
137
-
 
 
 
 
 
 
 
138
  widget_content = ""
139
  for index, (prompt, image) in enumerate(zip(downloaded_files["imagePrompt"], downloaded_files["imageName"])):
140
  escaped_prompt = prompt.replace("'", "''")
@@ -169,9 +176,7 @@ widget:
169
 
170
  {info["description"]}
171
 
172
- ## Trigger words
173
-
174
- You should use {formatted_words} to trigger the image generation.
175
 
176
  ## Download model
177
 
@@ -186,7 +191,7 @@ from diffusers import AutoPipelineForText2Image
186
  import torch
187
 
188
  pipeline = AutoPipelineForText2Image.from_pretrained('{info["baseModel"]}', torch_dtype=torch.float16).to('cuda')
189
- pipeline.load_lora_weights('{user_repo_id}', weight_name='{downloaded_files["weightName"]}')
190
  image = pipeline('{prompt if prompt else (formatted_words if formatted_words else 'Your custom prompt')}').images[0]
191
  ```
192
 
 
134
 
135
  trained_words = info['trainedWords'] if 'trainedWords' in info and info['trainedWords'] else []
136
  formatted_words = ', '.join(f'`{word}`' for word in trained_words)
137
+ if formatted_words:
138
+ trigger_words_section = f"""## Trigger words
139
+
140
+ You should use {formatted_words} to trigger the image generation.
141
+ """
142
+ else:
143
+ trigger_words_section = ""
144
+
145
  widget_content = ""
146
  for index, (prompt, image) in enumerate(zip(downloaded_files["imagePrompt"], downloaded_files["imageName"])):
147
  escaped_prompt = prompt.replace("'", "''")
 
176
 
177
  {info["description"]}
178
 
179
+ {trigger_words_section}
 
 
180
 
181
  ## Download model
182
 
 
191
  import torch
192
 
193
  pipeline = AutoPipelineForText2Image.from_pretrained('{info["baseModel"]}', torch_dtype=torch.float16).to('cuda')
194
+ pipeline.load_lora_weights('{user_repo_id}', weight_name='{downloaded_files["weightName"][0]}')
195
  image = pipeline('{prompt if prompt else (formatted_words if formatted_words else 'Your custom prompt')}').images[0]
196
  ```
197