Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from PIL import Image | |
| from transformers import pipeline | |
| import google.generativeai as genai | |
| # Configura tu API de Gemini | |
| genai.configure(api_key='AIzaSyBtzGXVrrY5_y99zVR-sSlZ_KEJI7HhuKs') | |
| gemini_model = genai.GenerativeModel('gemini-2.5-pro-exp-03-25') | |
| # Carga el modelo de Hugging Face BLIP (captioning) | |
| captioner = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base") | |
| # Interfaz Streamlit | |
| st.title("🗺️ Asistente Turístico Visual Inteligente") | |
| uploaded_file = st.file_uploader("Carga la imagen de un lugar turístico para darte informacion", type=['jpg', 'png', 'jpeg']) | |
| if uploaded_file is not None: | |
| image = Image.open(uploaded_file) | |
| st.image(image, caption='Imagen subida', use_container_width=True) | |
| if st.button("Generar información turística"): | |
| with st.spinner('🖼️ Identificando lugar...'): | |
| descripcion = captioner(image)[0]['generated_text'] | |
| st.markdown(f"**Hmmm... Parece ser que tu foto es:** _{descripcion}_") | |
| with st.spinner('📚 Generando información turística...'): | |
| prompt = f"""Genera información turística detallada sobre el siguiente lugar: {descripcion}. | |
| Incluye breve historia, datos curiosos, y recomendaciones para visitarlo.""" | |
| info = gemini_model.generate_content(prompt) | |
| st.markdown("### 📝 Información Turística:") | |
| st.write(info.text) | |