# app.py import streamlit as st from transformers import pipeline from PIL import Image import requests st.set_page_config(page_title="TinyLLaVA (Streamlit)", layout="centered") st.title("🦙 TinyLLaVA — Vision-Language Q&A") pipe = pipeline( task="image-to-text", model="bczhou/tiny-llava-v1-hf", trust_remote_code=True, device_map="cpu" ) uploaded_file = st.file_uploader("📷 Upload an image", type=["jpg","png","jpeg"]) prompt = st.text_input("💬 Ask a question (post `` token):", value="What is happening?") if uploaded_file and prompt: image = Image.open(uploaded_file).convert("RGB") st.image(image, caption="Uploaded Image", use_column_width=True) query = f"USER: \n{prompt}\nASSISTANT:" with st.spinner("Generating answer..."): result = pipe(query, image) answer = result[0]["generated_text"] st.subheader("📝 Answer:") st.write(answer)