image_to_prompt / app.py
nomanmanzoor's picture
Create app.py
82c76f8 verified
raw
history blame contribute delete
807 Bytes
import streamlit as st
from model import ImagePromptModel
import tempfile
st.set_page_config(page_title="🧠 Image to Prompt Generator", layout="centered")
st.title("🧠 Image-to-Prompt Model")
st.write("Upload an image to generate a creative caption using BLIP + Transformers.")
uploaded_file = st.file_uploader("πŸ“€ Upload Image", type=["jpg", "jpeg", "png"])
if uploaded_file:
with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
tmp_file.write(uploaded_file.read())
tmp_path = tmp_file.name
st.image(tmp_path, caption="Uploaded Image", use_column_width=True)
model = ImagePromptModel()
with st.spinner("Generating prompt..."):
result = model.generate_prompt(tmp_path)
st.success("βœ… Prompt Generated!")
st.write(f"**Prompt:** {result}")