artificialguybr
commited on
Commit
•
a166abf
1
Parent(s):
f0850f3
Update app.py
Browse files
app.py
CHANGED
@@ -16,11 +16,14 @@ with open('loras.json', 'r') as f:
|
|
16 |
|
17 |
def update_selection(selected_state: gr.SelectData):
|
18 |
logging.debug(f"Inside update_selection, selected_state: {selected_state}")
|
19 |
-
selected_lora_index = selected_state.index
|
20 |
selected_lora = loras[selected_lora_index]
|
21 |
new_placeholder = f"Type a prompt for {selected_lora['title']}"
|
|
|
|
|
22 |
return (
|
23 |
gr.update(placeholder=new_placeholder),
|
|
|
24 |
selected_state
|
25 |
)
|
26 |
|
@@ -73,7 +76,7 @@ with gr.Blocks(css="custom.css") as app:
|
|
73 |
"### This is my portfolio. Follow me on Twitter [@artificialguybr](https://twitter.com/artificialguybr). \n"
|
74 |
"**Note**: The speed and generation quality are for demonstration purposes. "
|
75 |
"For best quality, use Auto or Comfy or Diffusers. \n"
|
76 |
-
"**Warning**: The API might take some time to deliver the image. \n"
|
77 |
"Special thanks to Hugging Face for their free inference API."
|
78 |
)
|
79 |
selected_state = gr.State()
|
@@ -86,6 +89,7 @@ with gr.Blocks(css="custom.css") as app:
|
|
86 |
)
|
87 |
with gr.Column():
|
88 |
prompt_title = gr.Markdown("### Click on a LoRA in the gallery to select it")
|
|
|
89 |
with gr.Row():
|
90 |
prompt = gr.Textbox(label="Prompt", show_label=False, lines=1, max_lines=1, placeholder="Type a prompt after selecting a LoRA")
|
91 |
button = gr.Button("Run")
|
@@ -93,7 +97,7 @@ with gr.Blocks(css="custom.css") as app:
|
|
93 |
|
94 |
gallery.select(
|
95 |
update_selection,
|
96 |
-
outputs=[prompt, selected_state]
|
97 |
)
|
98 |
prompt.submit(
|
99 |
fn=run_lora,
|
|
|
16 |
|
17 |
def update_selection(selected_state: gr.SelectData):
|
18 |
logging.debug(f"Inside update_selection, selected_state: {selected_state}")
|
19 |
+
selected_lora_index = selected_state.index
|
20 |
selected_lora = loras[selected_lora_index]
|
21 |
new_placeholder = f"Type a prompt for {selected_lora['title']}"
|
22 |
+
lora_repo = selected_lora["repo"]
|
23 |
+
updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✨"
|
24 |
return (
|
25 |
gr.update(placeholder=new_placeholder),
|
26 |
+
gr.update(text=updated_text), # Atualiza o texto do Markdown
|
27 |
selected_state
|
28 |
)
|
29 |
|
|
|
76 |
"### This is my portfolio. Follow me on Twitter [@artificialguybr](https://twitter.com/artificialguybr). \n"
|
77 |
"**Note**: The speed and generation quality are for demonstration purposes. "
|
78 |
"For best quality, use Auto or Comfy or Diffusers. \n"
|
79 |
+
"**Warning**: The API might take some time to deliver the image. \n"
|
80 |
"Special thanks to Hugging Face for their free inference API."
|
81 |
)
|
82 |
selected_state = gr.State()
|
|
|
89 |
)
|
90 |
with gr.Column():
|
91 |
prompt_title = gr.Markdown("### Click on a LoRA in the gallery to select it")
|
92 |
+
selected_info = gr.Markdown("### Selected: None") # Inicializa com "None"
|
93 |
with gr.Row():
|
94 |
prompt = gr.Textbox(label="Prompt", show_label=False, lines=1, max_lines=1, placeholder="Type a prompt after selecting a LoRA")
|
95 |
button = gr.Button("Run")
|
|
|
97 |
|
98 |
gallery.select(
|
99 |
update_selection,
|
100 |
+
outputs=[prompt, selected_info, selected_state] # Adicionado selected_info aqui
|
101 |
)
|
102 |
prompt.submit(
|
103 |
fn=run_lora,
|