Spaces:
Sleeping
Sleeping
Update app.py
Browse filesOrganizar a Interface com gr.Accordion
app.py
CHANGED
|
@@ -787,7 +787,7 @@ def otimizar_prompt_imagem(descricao_pt, estilo_escolhido, filtro_escolhido):
|
|
| 787 |
|
| 788 |
def criar_negative_prompt():
|
| 789 |
"""Cria um prompt negativo padrão para evitar resultados ruins."""
|
| 790 |
-
return "low quality, blurry, (deformed hands:1.3), (bad anatomy:1.
|
| 791 |
|
| 792 |
def gerar_imagem_robusta(descricao_pt, estilo_escolhido, qualidade, filtro_escolhido, progress=None):
|
| 793 |
"""
|
|
@@ -1140,105 +1140,103 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
|
|
| 1140 |
with gr.TabItem("✨ Gerar Post", id=0):
|
| 1141 |
with gr.Row():
|
| 1142 |
with gr.Column(scale=1):
|
| 1143 |
-
|
| 1144 |
-
|
| 1145 |
-
|
| 1146 |
-
|
| 1147 |
-
|
| 1148 |
-
|
| 1149 |
-
|
| 1150 |
-
|
| 1151 |
-
|
| 1152 |
-
|
| 1153 |
-
|
| 1154 |
-
|
| 1155 |
-
|
| 1156 |
-
|
| 1157 |
-
|
| 1158 |
-
|
| 1159 |
-
|
| 1160 |
-
|
| 1161 |
-
|
| 1162 |
-
|
| 1163 |
|
| 1164 |
-
|
| 1165 |
-
|
| 1166 |
-
|
| 1167 |
-
|
| 1168 |
-
|
| 1169 |
-
|
| 1170 |
|
| 1171 |
-
with gr.
|
| 1172 |
-
gr.
|
| 1173 |
-
|
| 1174 |
-
|
| 1175 |
-
value=True,
|
| 1176 |
-
info="Reutiliza resultados anteriores (mais rápido)"
|
| 1177 |
)
|
| 1178 |
-
|
| 1179 |
-
|
| 1180 |
-
|
| 1181 |
-
|
|
|
|
| 1182 |
)
|
| 1183 |
-
|
| 1184 |
-
|
| 1185 |
-
|
| 1186 |
-
|
| 1187 |
-
|
| 1188 |
-
|
| 1189 |
-
|
| 1190 |
-
|
| 1191 |
-
|
| 1192 |
-
|
| 1193 |
-
|
| 1194 |
-
|
| 1195 |
-
|
| 1196 |
-
|
| 1197 |
-
|
| 1198 |
-
|
| 1199 |
-
|
| 1200 |
-
|
| 1201 |
-
|
| 1202 |
-
|
| 1203 |
-
|
| 1204 |
-
|
| 1205 |
-
|
| 1206 |
-
|
| 1207 |
-
|
| 1208 |
-
|
| 1209 |
-
|
| 1210 |
-
|
| 1211 |
-
|
| 1212 |
-
|
| 1213 |
-
|
| 1214 |
-
|
| 1215 |
-
|
| 1216 |
-
|
| 1217 |
-
|
| 1218 |
-
|
| 1219 |
-
|
| 1220 |
-
interactive=True
|
| 1221 |
-
)
|
| 1222 |
-
|
| 1223 |
-
def toggle_descricao_img(gerar):
|
| 1224 |
-
return (
|
| 1225 |
-
gr.Textbox(visible=gerar),
|
| 1226 |
-
gr.Dropdown(visible=gerar),
|
| 1227 |
-
gr.Radio(visible=gerar),
|
| 1228 |
-
gr.Dropdown(visible=gerar)
|
| 1229 |
)
|
| 1230 |
-
|
| 1231 |
-
gerar_img_checkbox.change(
|
| 1232 |
-
toggle_descricao_img,
|
| 1233 |
-
inputs=[gerar_img_checkbox],
|
| 1234 |
-
outputs=[descricao_img_input, estilo_img_input, qualidade_img_input, filtro_img_input]
|
| 1235 |
-
)
|
| 1236 |
-
|
| 1237 |
-
favorito_checkbox = gr.Checkbox(label="⭐ Favoritar este post?", value=False)
|
| 1238 |
|
| 1239 |
-
gr.
|
| 1240 |
-
|
| 1241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1242 |
|
| 1243 |
with gr.Column(scale=1):
|
| 1244 |
gr.Markdown("### 📋 3. Resultado")
|
|
@@ -1260,10 +1258,8 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
|
|
| 1260 |
editor_locked = gr.State(True)
|
| 1261 |
refinar_btn = gr.Button("✏️ Refinar Post")
|
| 1262 |
|
| 1263 |
-
gr.Markdown("ℹ️ *Use o ícone de prancheta (📋) no canto superior direito da caixa de texto para copiar o conteúdo.*")
|
| 1264 |
-
|
| 1265 |
with gr.Row():
|
| 1266 |
-
|
| 1267 |
limpar_btn = gr.Button("🧹 Limpar Tudo", variant="stop")
|
| 1268 |
|
| 1269 |
gr.Markdown("") # Espaçamento
|
|
@@ -1628,7 +1624,7 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
|
|
| 1628 |
fn=resetar_analytics,
|
| 1629 |
inputs=None,
|
| 1630 |
outputs=[analytics_display],
|
| 1631 |
-
js="() => confirm('Tem certeza que deseja resetar TODOS os dados de analytics e cache? Esta ação não pode ser desfeita.')"
|
| 1632 |
)
|
| 1633 |
|
| 1634 |
# Lançar aplicação
|
|
|
|
| 787 |
|
| 788 |
def criar_negative_prompt():
|
| 789 |
"""Cria um prompt negativo padrão para evitar resultados ruins."""
|
| 790 |
+
return "low quality, blurry, (deformed hands:1.3), (bad anatomy:1.loca3), (mutilated:1.2), (extra limbs:1.2), watermark, text, signature, ugly, tiling"
|
| 791 |
|
| 792 |
def gerar_imagem_robusta(descricao_pt, estilo_escolhido, qualidade, filtro_escolhido, progress=None):
|
| 793 |
"""
|
|
|
|
| 1140 |
with gr.TabItem("✨ Gerar Post", id=0):
|
| 1141 |
with gr.Row():
|
| 1142 |
with gr.Column(scale=1):
|
| 1143 |
+
# MELHORIA: gr.Accordion
|
| 1144 |
+
with gr.Accordion("⚙️ 1. Configurações do Texto", open=True):
|
| 1145 |
+
nicho_input = gr.Dropdown(
|
| 1146 |
+
choices=NICHOS_DISPONIVEIS,
|
| 1147 |
+
label="🎯 Nicho",
|
| 1148 |
+
value=NICHOS_DISPONIVEIS[0],
|
| 1149 |
+
interactive=True
|
| 1150 |
+
)
|
| 1151 |
+
|
| 1152 |
+
estilo_input = gr.Radio(
|
| 1153 |
+
choices=ESTILOS_DISPONIVEIS,
|
| 1154 |
+
label="🎨 Estilo",
|
| 1155 |
+
value=ESTILOS_DISPONIVEIS[0],
|
| 1156 |
+
interactive=True
|
| 1157 |
+
)
|
| 1158 |
+
|
| 1159 |
+
tema_input = gr.Textbox(
|
| 1160 |
+
label="📝 Tema do Post",
|
| 1161 |
+
placeholder="Ex: Transforme seu corpo, transforme sua vida"
|
| 1162 |
+
)
|
| 1163 |
|
| 1164 |
+
formato_input = gr.Radio(
|
| 1165 |
+
choices=list(FORMATO_CONFIGS.keys()),
|
| 1166 |
+
label="📄 Formato de Saída",
|
| 1167 |
+
value=list(FORMATO_CONFIGS.keys())[0],
|
| 1168 |
+
interactive=True
|
| 1169 |
+
)
|
| 1170 |
|
| 1171 |
+
with gr.Accordion("🎨 2. Configurações da Imagem (Opcional)", open=False):
|
| 1172 |
+
gerar_img_checkbox = gr.Checkbox(
|
| 1173 |
+
label="Gerar imagem?",
|
| 1174 |
+
value=False
|
|
|
|
|
|
|
| 1175 |
)
|
| 1176 |
+
|
| 1177 |
+
descricao_img_input = gr.Textbox(
|
| 1178 |
+
label="📸 Descrição da imagem (em Português)",
|
| 1179 |
+
placeholder="Ex: Pessoa correndo ao nascer do sol",
|
| 1180 |
+
visible=False
|
| 1181 |
)
|
| 1182 |
+
|
| 1183 |
+
estilo_img_input = gr.Dropdown(
|
| 1184 |
+
label="🖼️ Estilo da Imagem",
|
| 1185 |
+
choices=list(ESTILOS_DE_IMAGEM.keys()),
|
| 1186 |
+
value="Nenhum (Automático)",
|
| 1187 |
+
visible=False,
|
| 1188 |
+
interactive=True
|
| 1189 |
+
)
|
| 1190 |
+
|
| 1191 |
+
qualidade_img_input = gr.Radio(
|
| 1192 |
+
label="⏱️ Qualidade da Imagem",
|
| 1193 |
+
choices=["Rápida", "Balanceada", "Alta"],
|
| 1194 |
+
value="Balanceada",
|
| 1195 |
+
visible=False,
|
| 1196 |
+
interactive=True
|
| 1197 |
+
)
|
| 1198 |
+
|
| 1199 |
+
filtro_img_input = gr.Dropdown(
|
| 1200 |
+
label="🌈 Filtro da Imagem",
|
| 1201 |
+
choices=list(FILTROS_IMAGEM.keys()),
|
| 1202 |
+
value="Nenhum",
|
| 1203 |
+
visible=False,
|
| 1204 |
+
interactive=True
|
| 1205 |
+
)
|
| 1206 |
+
|
| 1207 |
+
def toggle_descricao_img(gerar):
|
| 1208 |
+
return (
|
| 1209 |
+
gr.Textbox(visible=gerar),
|
| 1210 |
+
gr.Dropdown(visible=gerar),
|
| 1211 |
+
gr.Radio(visible=gerar),
|
| 1212 |
+
gr.Dropdown(visible=gerar)
|
| 1213 |
+
)
|
| 1214 |
+
|
| 1215 |
+
gerar_img_checkbox.change(
|
| 1216 |
+
toggle_descricao_img,
|
| 1217 |
+
inputs=[gerar_img_checkbox],
|
| 1218 |
+
outputs=[descricao_img_input, estilo_img_input, qualidade_img_input, filtro_img_input]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1219 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1220 |
|
| 1221 |
+
with gr.Accordion("⚡ Performance e Ações", open=True):
|
| 1222 |
+
with gr.Group():
|
| 1223 |
+
gr.Markdown("### ⚡ Performance")
|
| 1224 |
+
usar_cache_checkbox = gr.Checkbox(
|
| 1225 |
+
label="Usar cache",
|
| 1226 |
+
value=True,
|
| 1227 |
+
info="Reutiliza resultados anteriores (mais rápido)"
|
| 1228 |
+
)
|
| 1229 |
+
limpar_cache_btn = gr.Button(
|
| 1230 |
+
"🗑️ Limpar Cache",
|
| 1231 |
+
size="sm",
|
| 1232 |
+
variant="secondary"
|
| 1233 |
+
)
|
| 1234 |
+
|
| 1235 |
+
gr.Markdown("") # Espaçamento
|
| 1236 |
+
favorito_checkbox = gr.Checkbox(label="⭐ Favoritar este post?", value=False)
|
| 1237 |
+
|
| 1238 |
+
gr.Markdown("") # Espaçamento
|
| 1239 |
+
gerar_btn = gr.Button("✨ Gerar Post", variant="primary")
|
| 1240 |
|
| 1241 |
with gr.Column(scale=1):
|
| 1242 |
gr.Markdown("### 📋 3. Resultado")
|
|
|
|
| 1258 |
editor_locked = gr.State(True)
|
| 1259 |
refinar_btn = gr.Button("✏️ Refinar Post")
|
| 1260 |
|
|
|
|
|
|
|
| 1261 |
with gr.Row():
|
| 1262 |
+
copiar_btn = gr.Button("📋 Copiar Texto", variant="secondary")
|
| 1263 |
limpar_btn = gr.Button("🧹 Limpar Tudo", variant="stop")
|
| 1264 |
|
| 1265 |
gr.Markdown("") # Espaçamento
|
|
|
|
| 1624 |
fn=resetar_analytics,
|
| 1625 |
inputs=None,
|
| 1626 |
outputs=[analytics_display],
|
| 1627 |
+
js="() => { return confirm('Tem certeza que deseja resetar TODOS os dados de analytics e cache? Esta ação não pode ser desfeita.') }"
|
| 1628 |
)
|
| 1629 |
|
| 1630 |
# Lançar aplicação
|