linoyts HF Staff commited on
Commit
2fa2744
·
verified ·
1 Parent(s): 79fe329

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -123,6 +123,13 @@ def create_interface():
123
  "Snoopy", "Van_Gogh", "Vector"
124
  ]
125
 
 
 
 
 
 
 
 
126
  # Example data
127
  examples = [
128
  ["3D_Chibi", "", "3D Chibi style, Two smiling colleagues enthusiastically high-five in front of a whiteboard filled with technical notes about multimodal learning, reflecting a moment of success and collaboration at OpenAI.",
@@ -154,7 +161,7 @@ def create_interface():
154
  with gr.Column(scale=1):
155
  image_input = gr.Image(type="pil", label="Upload Image")
156
  prompt_box = gr.Textbox(label="Prompt",
157
- placeholder="Enter your prompt here",
158
  info="Remember to include the necessary trigger words if you're using a custom LoRA."
159
  )
160
  lora_dropdown = gr.Dropdown(
@@ -177,6 +184,9 @@ def create_interface():
177
  seed_slider = gr.Slider(
178
  1, 2_147_483_647, value=42, step=1, label="Seed")
179
 
 
 
 
180
  gr.Examples(
181
  examples=examples,
182
  inputs=[lora_dropdown, custom_repo_box, prompt_box, image_input,
 
123
  "Snoopy", "Van_Gogh", "Vector"
124
  ]
125
 
126
+ def update_trigger_word(lora_name, prompt):
127
+ for name in demo_lora_names:
128
+ trigger = " ".join(name.split("_")) + " style,"
129
+ prompt = prompt.replace(trigger, "")
130
+ new_trigger = " ".join(lora_name.split("_"))+ " style,"
131
+ return new_trigger + prompt
132
+
133
  # Example data
134
  examples = [
135
  ["3D_Chibi", "", "3D Chibi style, Two smiling colleagues enthusiastically high-five in front of a whiteboard filled with technical notes about multimodal learning, reflecting a moment of success and collaboration at OpenAI.",
 
161
  with gr.Column(scale=1):
162
  image_input = gr.Image(type="pil", label="Upload Image")
163
  prompt_box = gr.Textbox(label="Prompt",
164
+ value="3D Chibi style,",
165
  info="Remember to include the necessary trigger words if you're using a custom LoRA."
166
  )
167
  lora_dropdown = gr.Dropdown(
 
184
  seed_slider = gr.Slider(
185
  1, 2_147_483_647, value=42, step=1, label="Seed")
186
 
187
+ lora_dropdown.select(fn=update_trigger_word, inputs=[lora_dropdown,prompt_box],
188
+ outputs=prompt_box)
189
+
190
  gr.Examples(
191
  examples=examples,
192
  inputs=[lora_dropdown, custom_repo_box, prompt_box, image_input,