Osc17-2003 commited on
Commit
752a4d9
·
verified ·
1 Parent(s): 70ed0a6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image
3
+ from transformers import pipeline
4
+ import google.generativeai as genai
5
+
6
+ # Configura tu API de Gemini
7
+ genai.configure(api_key='TU_API_KEY_GEMINI')
8
+ gemini_model = genai.GenerativeModel('gemini-pro')
9
+
10
+ # Carga el modelo de Hugging Face BLIP (captioning)
11
+ captioner = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base")
12
+
13
+ # Interfaz Streamlit
14
+ st.title("🗺️ Asistente Turístico Visual Inteligente")
15
+
16
+ uploaded_file = st.file_uploader("Carga la imagen de un lugar turístico", type=['jpg', 'png', 'jpeg'])
17
+
18
+ if uploaded_file is not None:
19
+ image = Image.open(uploaded_file)
20
+ st.image(image, caption='Imagen subida', use_column_width=True)
21
+
22
+ if st.button("Generar información turística"):
23
+ with st.spinner('🖼️ Identificando lugar...'):
24
+ descripcion = captioner(image)[0]['generated_text']
25
+ st.markdown(f"**Descripción visual generada:** _{descripcion}_")
26
+
27
+ with st.spinner('📚 Generando información turística con Gemini...'):
28
+ prompt = f"""Genera información turística detallada sobre el siguiente lugar: {descripcion}.
29
+ Incluye breve historia, datos curiosos, y recomendaciones para visitarlo."""
30
+ info = gemini_model.generate_content(prompt)
31
+ st.markdown("### 📝 Información Turística:")
32
+ st.write(info.text)