Delete app.py
Browse files
app.py
DELETED
@@ -1,90 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from transformers import pipeline
|
3 |
-
|
4 |
-
# Configuración de la página
|
5 |
-
st.set_page_config(
|
6 |
-
page_title="¿No sabes qué decir? Te ayudamos",
|
7 |
-
page_icon="💡",
|
8 |
-
layout="centered"
|
9 |
-
)
|
10 |
-
|
11 |
-
# Estilos personalizados en colores pasteles
|
12 |
-
st.markdown(
|
13 |
-
"""
|
14 |
-
<style>
|
15 |
-
body {
|
16 |
-
background-color: #fefaf4;
|
17 |
-
}
|
18 |
-
.title {
|
19 |
-
font-size: 38px;
|
20 |
-
font-weight: bold;
|
21 |
-
text-align: center;
|
22 |
-
color: #a3b18a; /* Verde pastel */
|
23 |
-
margin-bottom: 10px;
|
24 |
-
}
|
25 |
-
.subtitle {
|
26 |
-
font-size: 18px;
|
27 |
-
text-align: center;
|
28 |
-
color: #588157; /* Verde más oscuro pastel */
|
29 |
-
}
|
30 |
-
.footer {
|
31 |
-
text-align: center;
|
32 |
-
font-size: 12px;
|
33 |
-
margin-top: 30px;
|
34 |
-
color: #8d99ae; /* Gris pastel */
|
35 |
-
}
|
36 |
-
.stTextInput>div>div>input {
|
37 |
-
background-color: #f9f9f9;
|
38 |
-
color: #3d405b; /* Texto oscuro pastel */
|
39 |
-
}
|
40 |
-
.stButton>button {
|
41 |
-
background-color: #ffdab9; /* Naranja pastel */
|
42 |
-
color: #3d405b;
|
43 |
-
font-size: 16px;
|
44 |
-
}
|
45 |
-
</style>
|
46 |
-
""",
|
47 |
-
unsafe_allow_html=True
|
48 |
-
)
|
49 |
-
|
50 |
-
# Título llamativo
|
51 |
-
st.markdown('<p class="title">¿No sabes qué decir? 💡</p>', unsafe_allow_html=True)
|
52 |
-
st.markdown('<p class="subtitle">¡Te ayudamos a completar tus ideas con inteligencia artificial!</p>', unsafe_allow_html=True)
|
53 |
-
|
54 |
-
# Imagen decorativa
|
55 |
-
st.image("https://i.imgur.com/LgJrMFP.png", caption="Procesamiento de texto optimizado con AI 💻", use_column_width=True)
|
56 |
-
|
57 |
-
# Cargar modelo en español optimizado
|
58 |
-
@st.cache_resource
|
59 |
-
def load_model():
|
60 |
-
return pipeline("text-generation", model="datificate/gpt2-small-spanish")
|
61 |
-
|
62 |
-
generator = load_model()
|
63 |
-
|
64 |
-
# Entrada del usuario
|
65 |
-
st.subheader("📝 Escribe tu idea:")
|
66 |
-
prompt = st.text_area("Completa tu idea:", placeholder="Ejemplo: Me gustaría escribir una carta a...")
|
67 |
-
|
68 |
-
# Generar respuesta
|
69 |
-
if st.button("✨ Generar Texto ✨"):
|
70 |
-
if not prompt.strip():
|
71 |
-
st.warning(⚠️ Por favor, ingresa un texto válido.")
|
72 |
-
else:
|
73 |
-
with st.spinner("⏳ Generando texto..."):
|
74 |
-
result = generator(
|
75 |
-
prompt,
|
76 |
-
max_length=20, # Texto más corto
|
77 |
-
temperature=0.2, # Muy baja creatividad
|
78 |
-
top_p=0.7, # Sampling controlado
|
79 |
-
top_k=20, # Limitación de palabras más probables
|
80 |
-
repetition_penalty=1.5, # Penalización de repeticiones
|
81 |
-
num_return_sequences=1,
|
82 |
-
eos_token_id=50256,
|
83 |
-
do_sample=False
|
84 |
-
)
|
85 |
-
response = result[0]["generated_text"]
|
86 |
-
st.subheader("🖋️ Texto Generado:")
|
87 |
-
st.success(response)
|
88 |
-
|
89 |
-
# Footer del grupo
|
90 |
-
st.markdown('<p class="footer">Grupo 7 - Procesamiento de datos con AI - Especialización de Inteligencia Artificial UAO</p>', unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|