Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
import openai
|
| 5 |
import os
|
|
@@ -13,7 +13,7 @@ from streamlit_webrtc import webrtc_streamer, WebRtcMode, AudioProcessorBase
|
|
| 13 |
# Configuraci贸n de la clave API
|
| 14 |
load_dotenv()
|
| 15 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 16 |
-
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] ="botidinamix-g.json"
|
| 17 |
|
| 18 |
# Configuraci贸n de Streamlit
|
| 19 |
st.set_page_config(page_title="Asistente Teol贸gico", page_icon="馃摉")
|
|
@@ -77,7 +77,7 @@ page = st.sidebar.selectbox("Selecciona una p谩gina", ["Chat Asistente", "Gesti
|
|
| 77 |
# Cargar el modelo de Hugging Face
|
| 78 |
@st.cache(allow_output_mutation=True)
|
| 79 |
def cargar_modelo():
|
| 80 |
-
return
|
| 81 |
|
| 82 |
modelo_generacion_imagenes = cargar_modelo()
|
| 83 |
|
|
@@ -152,8 +152,7 @@ elif page == "Generador de Frases B铆blicas":
|
|
| 152 |
# Funci贸n para generar una imagen alusiva usando Hugging Face
|
| 153 |
def generar_imagen(frase):
|
| 154 |
try:
|
| 155 |
-
|
| 156 |
-
image = images[0]["generated_image"]
|
| 157 |
return image
|
| 158 |
except Exception as e:
|
| 159 |
st.error(f"Error al generar la imagen: {e}")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from diffusers import StableDiffusionPipeline
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
import openai
|
| 5 |
import os
|
|
|
|
| 13 |
# Configuraci贸n de la clave API
|
| 14 |
load_dotenv()
|
| 15 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 16 |
+
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "botidinamix-g.json"
|
| 17 |
|
| 18 |
# Configuraci贸n de Streamlit
|
| 19 |
st.set_page_config(page_title="Asistente Teol贸gico", page_icon="馃摉")
|
|
|
|
| 77 |
# Cargar el modelo de Hugging Face
|
| 78 |
@st.cache(allow_output_mutation=True)
|
| 79 |
def cargar_modelo():
|
| 80 |
+
return StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")
|
| 81 |
|
| 82 |
modelo_generacion_imagenes = cargar_modelo()
|
| 83 |
|
|
|
|
| 152 |
# Funci贸n para generar una imagen alusiva usando Hugging Face
|
| 153 |
def generar_imagen(frase):
|
| 154 |
try:
|
| 155 |
+
image = modelo_generacion_imagenes(frase).images[0]
|
|
|
|
| 156 |
return image
|
| 157 |
except Exception as e:
|
| 158 |
st.error(f"Error al generar la imagen: {e}")
|