Spaces:
Running
on
Zero
Running
on
Zero
Update app.py (#6)
Browse files- Update app.py (af059198a3f33fd7b630e95be9308abe0c16a181)
app.py
CHANGED
@@ -59,7 +59,7 @@ def update_selection(selected_state: gr.SelectData, flux_loras):
|
|
59 |
trigger_word = flux_loras[selected_state.index]["trigger_word"]
|
60 |
|
61 |
updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo})"
|
62 |
-
new_placeholder = f"
|
63 |
|
64 |
return updated_text, gr.update(placeholder=new_placeholder), selected_state.index
|
65 |
|
@@ -172,17 +172,22 @@ def infer_with_lora(input_image, prompt, selected_index, custom_lora, seed=42, r
|
|
172 |
trigger_word = lora_to_use["trigger_word"]
|
173 |
is_kontext_lora = lora_to_use["lora_type"] == "kontext"
|
174 |
if not is_kontext_lora:
|
175 |
-
if trigger_word == ", How2Draw":
|
176 |
-
prompt = f"create a How2Draw sketch of the person of the photo {prompt}, maintain the facial identity of the person and general features"
|
177 |
-
elif trigger_word == ", video game screenshot in the style of THSMS":
|
178 |
-
prompt = f"create a video game screenshot in the style of THSMS with the person from the photo, {prompt}. maintain the facial identity of the person and general features"
|
179 |
-
else:
|
180 |
-
prompt = f"convert the style of this portrait photo to {trigger_word} while maintaining the identity of the person. {prompt}. Make sure to maintain the person's facial identity and features, while still changing the overall style to {trigger_word}."
|
181 |
-
else:
|
182 |
if portrait_mode:
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
184 |
else:
|
185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
try:
|
187 |
image = pipe(
|
188 |
image=input_image,
|
@@ -239,7 +244,7 @@ with gr.Blocks(css=css) as demo:
|
|
239 |
|
240 |
title = gr.HTML(
|
241 |
"""<h1> FLUX.1 Kontext Portrait 👩🏻🎤
|
242 |
-
<br><small style="font-size: 13px; opacity: 0.75;">Flux.1 Kontext [dev] + community Flux LoRAs 🤗</small></h1>""",
|
243 |
)
|
244 |
|
245 |
selected_state = gr.State(value=None)
|
@@ -274,7 +279,7 @@ with gr.Blocks(css=css) as demo:
|
|
274 |
show_label=False,
|
275 |
lines=1,
|
276 |
max_lines=1,
|
277 |
-
placeholder="
|
278 |
elem_id="prompt"
|
279 |
)
|
280 |
run_button = gr.Button("Generate", elem_id="run_button")
|
|
|
59 |
trigger_word = flux_loras[selected_state.index]["trigger_word"]
|
60 |
|
61 |
updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo})"
|
62 |
+
new_placeholder = f"opt - describe the person/subject, e.g. 'a man with glasses and a beard'"
|
63 |
|
64 |
return updated_text, gr.update(placeholder=new_placeholder), selected_state.index
|
65 |
|
|
|
172 |
trigger_word = lora_to_use["trigger_word"]
|
173 |
is_kontext_lora = lora_to_use["lora_type"] == "kontext"
|
174 |
if not is_kontext_lora:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
if portrait_mode:
|
176 |
+
if trigger_word == ", How2Draw":
|
177 |
+
prompt = f"create a How2Draw sketch of the person of the photo {prompt}, maintain the facial identity of the person and general features"
|
178 |
+
elif trigger_word == ", video game screenshot in the style of THSMS":
|
179 |
+
prompt = f"create a video game screenshot in the style of THSMS with the person from the photo, {prompt}. maintain the facial identity of the person and general features"
|
180 |
+
else:
|
181 |
+
prompt = f"convert the style of this portrait photo to {trigger_word} while maintaining the identity of the person. {prompt}. Make sure to maintain the person's facial identity and features, while still changing the overall style to {trigger_word}."
|
182 |
else:
|
183 |
+
if trigger_word == ", How2Draw":
|
184 |
+
prompt = f"create a How2Draw sketch of the photo {prompt}"
|
185 |
+
elif trigger_word == ", video game screenshot in the style of THSMS":
|
186 |
+
prompt = f"create a video game screenshot in the style of THSMS of the photo, {prompt}."
|
187 |
+
else:
|
188 |
+
prompt = f"convert the style of this photo {prompt} to {trigger_word}."
|
189 |
+
else:
|
190 |
+
prompt = f"{trigger_word}. {prompt}."
|
191 |
try:
|
192 |
image = pipe(
|
193 |
image=input_image,
|
|
|
244 |
|
245 |
title = gr.HTML(
|
246 |
"""<h1> FLUX.1 Kontext Portrait 👩🏻🎤
|
247 |
+
<br><small style="font-size: 13px; opacity: 0.75;">Flux.1 Kontext [dev] + community Kontext & Flux LoRAs 🤗</small></h1>""",
|
248 |
)
|
249 |
|
250 |
selected_state = gr.State(value=None)
|
|
|
279 |
show_label=False,
|
280 |
lines=1,
|
281 |
max_lines=1,
|
282 |
+
placeholder="opt - describe the person/subject, e.g. 'a man with glasses and a beard'",
|
283 |
elem_id="prompt"
|
284 |
)
|
285 |
run_button = gr.Button("Generate", elem_id="run_button")
|