Spaces:
Build error
Build error
File size: 761 Bytes
725566b d3e1bc0 725566b d3e1bc0 725566b d3e1bc0 725566b d3e1bc0 725566b d3e1bc0 725566b d3e1bc0 725566b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import streamlit as st
from PIL import Image
from transformers import pipeline
# Create an image captioning pipeline using Hugging Face Transformers
image_captioner = pipeline("image-captioning")
# Streamlit app header
st.title("Hugging Face Transformer Image-to-Text App")
# File uploader for image
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "png", "jpeg"])
if uploaded_image:
# Display the uploaded image
image = Image.open(uploaded_image)
st.image(image, caption="Uploaded Image", use_column_width=True)
# Perform image captioning when an image is uploaded
caption = image_captioner(uploaded_image)[0]["caption"]
# Display the generated caption
st.subheader("Generated Caption:")
st.write(caption) |