Update app.py
Browse files
app.py
CHANGED
@@ -295,7 +295,7 @@ class calculateDuration:
|
|
295 |
|
296 |
def update_selection(evt: gr.SelectData, width, height):
|
297 |
selected_lora = loras[evt.index]
|
298 |
-
new_placeholder = f"Digite o prompt para {selected_lora['title']}"
|
299 |
lora_repo = selected_lora["repo"]
|
300 |
updated_text = f"### Selecionado: [{lora_repo}](https://huggingface.co/{lora_repo}) ✅"
|
301 |
if "aspect" in selected_lora:
|
@@ -448,43 +448,43 @@ def check_custom_model(link):
|
|
448 |
else:
|
449 |
return get_huggingface_safetensors(link)
|
450 |
|
451 |
-
def add_custom_lora(custom_lora):
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
<small>{"Usando: <code><b>"+trigger_word+"</code></b> como palavra-chave" if trigger_word else "Não encontramos a palavra-chave, se tiver, coloque-a no prompt."}<br></small>
|
465 |
-
|
466 |
-
|
467 |
-
</div>
|
468 |
-
'''
|
469 |
-
existing_item_index = next((index for (index, item) in enumerate(loras) if item['repo'] == repo), None)
|
470 |
-
if(not existing_item_index):
|
471 |
-
new_item = {
|
472 |
-
"image": image,
|
473 |
-
"title": title,
|
474 |
-
"repo": repo,
|
475 |
-
"weights": path,
|
476 |
-
"trigger_word": trigger_word
|
477 |
-
}
|
478 |
-
print(new_item)
|
479 |
-
existing_item_index = len(loras)
|
480 |
-
loras.append(new_item)
|
481 |
-
|
482 |
-
return gr.update(visible=True, value=card), gr.update(visible=True), gr.Gallery(selected_index=None), f"Custom: {path}", existing_item_index, trigger_word
|
483 |
-
except Exception as e:
|
484 |
-
gr.Warning(f"Modelo Inválido: ou o link está errado ou não é um FLUX")
|
485 |
-
return gr.update(visible=True, value=f"Modelo Inválido: ou o link está errado ou não é um FLUX"), gr.update(visible=False), gr.update(), "", None, ""
|
486 |
-
else:
|
487 |
-
return gr.update(visible=False), gr.update(visible=False), gr.update(), "", None, ""
|
488 |
|
489 |
def remove_custom_lora():
|
490 |
return gr.update(visible=False), gr.update(visible=False), gr.update(), "", None, ""
|
@@ -531,11 +531,17 @@ with gr.Blocks(theme=collos, delete_cache=(60, 60)) as app:
|
|
531 |
columns=3,
|
532 |
show_share_button=False
|
533 |
)
|
|
|
|
|
|
|
|
|
|
|
534 |
with gr.Group():
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
|
|
539 |
with gr.Column():
|
540 |
progress_bar = gr.Markdown(elem_id="progress", visible=False)
|
541 |
result = gr.Image(label="Imagem Gerada")
|
|
|
295 |
|
296 |
def update_selection(evt: gr.SelectData, width, height):
|
297 |
selected_lora = loras[evt.index]
|
298 |
+
new_placeholder = f"Digite o prompt para {selected_lora['title'] de preferência em inglês.}"
|
299 |
lora_repo = selected_lora["repo"]
|
300 |
updated_text = f"### Selecionado: [{lora_repo}](https://huggingface.co/{lora_repo}) ✅"
|
301 |
if "aspect" in selected_lora:
|
|
|
448 |
else:
|
449 |
return get_huggingface_safetensors(link)
|
450 |
|
451 |
+
# def add_custom_lora(custom_lora):
|
452 |
+
# global loras
|
453 |
+
# if(custom_lora):
|
454 |
+
# try:
|
455 |
+
# title, repo, path, trigger_word, image = check_custom_model(custom_lora)
|
456 |
+
# print(f"Modelo Externo: {repo}")
|
457 |
+
# card = f'''
|
458 |
+
# <div class="custom_lora_card">
|
459 |
+
# <span>Loaded custom LoRA:</span>
|
460 |
+
# <div class="card_internal">
|
461 |
+
# <img src="{image}" />
|
462 |
+
# <div>
|
463 |
+
# <h3>{title}</h3>
|
464 |
+
# <small>{"Usando: <code><b>"+trigger_word+"</code></b> como palavra-chave" if trigger_word else "Não encontramos a palavra-chave, se tiver, coloque-a no prompt."}<br></small>
|
465 |
+
# </div>
|
466 |
+
# </div>
|
467 |
+
# </div>
|
468 |
+
# '''
|
469 |
+
# existing_item_index = next((index for (index, item) in enumerate(loras) if item['repo'] == repo), None)
|
470 |
+
# if(not existing_item_index):
|
471 |
+
# new_item = {
|
472 |
+
# "image": image,
|
473 |
+
# "title": title,
|
474 |
+
# "repo": repo,
|
475 |
+
# "weights": path,
|
476 |
+
# "trigger_word": trigger_word
|
477 |
+
# }
|
478 |
+
# print(new_item)
|
479 |
+
# existing_item_index = len(loras)
|
480 |
+
# loras.append(new_item)
|
481 |
+
#
|
482 |
+
# return gr.update(visible=True, value=card), gr.update(visible=True), gr.Gallery(selected_index=None), f"Custom: {path}", existing_item_index, trigger_word
|
483 |
+
# except Exception as e:
|
484 |
+
# gr.Warning(f"Modelo Inválido: ou o link está errado ou não é um FLUX")
|
485 |
+
# return gr.update(visible=True, value=f"Modelo Inválido: ou o link está errado ou não é um FLUX"), gr.update(visible=False), gr.update(), "", None, ""
|
486 |
+
# else:
|
487 |
+
# return gr.update(visible=False), gr.update(visible=False), gr.update(), "", None, ""
|
488 |
|
489 |
def remove_custom_lora():
|
490 |
return gr.update(visible=False), gr.update(visible=False), gr.update(), "", None, ""
|
|
|
531 |
columns=3,
|
532 |
show_share_button=False
|
533 |
)
|
534 |
+
# with gr.Group():
|
535 |
+
# custom_lora = gr.Textbox(label="Selecione um Modelo Externo", placeholder="black-forest-labs/FLUX.1-dev")
|
536 |
+
# gr.Markdown("[Cheque a lista de modelos do Huggingface](https://huggingface.co/models?other=base_model:adapter:black-forest-labs/FLUX.1-dev)", elem_id="lora_list")
|
537 |
+
# custom_lora_info = gr.HTML(visible=False)
|
538 |
+
# custom_lora_button = gr.Button("Remova modelo Externo", visible=False)
|
539 |
with gr.Group():
|
540 |
+
gr.Markdown(
|
541 |
+
"""
|
542 |
+
### Dica de Uso!
|
543 |
+
Sempre digite a Palavra-chave referente ao modelo que são: José Alves, Júlio, Pedro e Clóvis, com os devidos acentos.
|
544 |
+
""")
|
545 |
with gr.Column():
|
546 |
progress_bar = gr.Markdown(elem_id="progress", visible=False)
|
547 |
result = gr.Image(label="Imagem Gerada")
|