| import streamlit as st |
| from diffusers import DiffusionPipeline |
| import requests |
|
|
| |
| LLAMA_API_URL = "https://api-inference.huggingface.co/models/meta-llama/Llama-3.2-11B-Vision-Instruct" |
| FLUX_API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev" |
| COGVIDEO_API_URL = DiffusionPipeline.from_pretrained("bertjiazheng/KoolCogVideoX-5b") |
|
|
|
|
| st.title("ChatBot Multi-IA") |
|
|
| |
| st.header("Chat y an谩lisis de im谩genes") |
|
|
| |
| user_input = st.text_area("Escribe tu pregunta o sube una imagen para analizar", "") |
|
|
| |
| uploaded_image = st.file_uploader("Sube una imagen para que la IA la analice", type=["png", "jpg", "jpeg"]) |
|
|
| |
| if st.button("Enviar para an谩lisis"): |
| if uploaded_image: |
| |
| files = {"image": uploaded_image.getvalue()} |
| response = requests.post(LLAMA_API_URL, files=files) |
| st.image(uploaded_image, caption="Imagen subida", use_column_width=True) |
| st.write("Respuesta de an谩lisis:", response.text) |
| elif user_input: |
| |
| data = {"text": user_input} |
| response = requests.post(LLAMA_API_URL, json=data) |
| st.write("Respuesta del chat:", response.text) |
| else: |
| st.warning("Escribe algo o sube una imagen para an谩lisis") |
|
|
| |
| st.header("Generaci贸n de im谩genes") |
|
|
| |
| image_prompt = st.text_input("Describe la imagen que deseas generar", "") |
|
|
| |
| if st.button("Generar imagen"): |
| if image_prompt: |
| |
| data = {"prompt": image_prompt} |
| response = requests.post(FLUX_API_URL, json=data) |
| st.image(response.content, caption="Imagen generada", use_column_width=True) |
| else: |
| st.warning("Por favor, ingresa una descripci贸n para generar una imagen.") |
|
|
| |
| st.header("Generaci贸n de video") |
|
|
| |
| video_prompt = st.text_input("Describe el video que deseas generar", "") |
|
|
| |
| if st.button("Generar video"): |
| if video_prompt: |
| |
| data = {"prompt": video_prompt} |
| response = requests.post(COGVIDEO_API_URL, json=data) |
| |
| with open("video_generado.mp4", "wb") as f: |
| f.write(response.content) |
| st.video("video_generado.mp4") |
| else: |
| st.warning("Por favor, ingresa una descripci贸n para generar un video.") |
|
|
| |
| st.write("Aplicaci贸n que combina chat, generaci贸n de im谩genes y videos con m煤ltiples IAs.") |
|
|