File size: 595 Bytes
ce47c87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import streamlit as st
import requests
from PIL import Image

st.title("Image Captioning with Fine-Tuned BLiPv2 Model")

uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])

if uploaded_file is not None:
    image = Image.open(uploaded_file)
    st.image(image, caption="Uploaded Image", use_column_width=True)
    
    files = {"file": uploaded_file.getvalue()}
    response = requests.post("http://localhost:8501/generate-caption/", files=files)
    caption = response.json().get("caption")
    
    st.write("Generated Caption:")
    st.write(f"**{caption}**")