Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
.stButton>button {
|
37 |
+
background-color: #ffdab9; /* Naranja pastel */
|
38 |
+
color: #3d405b;
|
39 |
+
font-size: 16px;
|
40 |
+
}
|
41 |
+
</style>
|
42 |
+
""",
|
43 |
+
unsafe_allow_html=True
|
44 |
+
)
|
45 |
+
|
46 |
+
# Título llamativo
|
47 |
+
st.markdown('<p class="title">¿No sabes qué decir? 💡</p>', unsafe_allow_html=True)
|
48 |
+
st.markdown('<p class="subtitle">¡Te ayudamos a completar tus ideas con inteligencia artificial!</p>', unsafe_allow_html=True)
|
49 |
+
|
50 |
+
# Entrada del usuario
|
51 |
+
st.subheader("📝 Escribe tu idea:")
|
52 |
+
prompt = st.text_area("Completa tu idea:", placeholder="Ejemplo: Me gustaría escribir una carta a...")
|
53 |
+
|
54 |
+
# Generar respuesta
|
55 |
+
if st.button("✨ Generar Texto ✨"):
|
56 |
+
st.info("Cargando modelo... esto puede tardar unos segundos.")
|
57 |
+
with st.spinner("⏳ Generando texto..."):
|
58 |
+
generator = pipeline("text-generation", model="datificate/gpt2-small-spanish")
|
59 |
+
result = generator(
|
60 |
+
prompt,
|
61 |
+
max_length=20,
|
62 |
+
temperature=0.2,
|
63 |
+
top_p=0.7,
|
64 |
+
top_k=20,
|
65 |
+
repetition_penalty=1.5,
|
66 |
+
num_return_sequences=1,
|
67 |
+
eos_token_id=50256,
|
68 |
+
do_sample=False
|
69 |
+
)
|
70 |
+
response = result[0]["generated_text"]
|
71 |
+
st.subheader("🖋️ Texto Generado:")
|
72 |
+
st.success(response)
|
73 |
+
|
74 |
+
# Footer del grupo
|
75 |
+
st.markdown('<p class="footer">Grupo 7 - Procesamiento de datos con AI - Especialización de Inteligencia Artificial UAO</p>', unsafe_allow_html=True)
|