File size: 481 Bytes
4267968
8f052d9
2eba408
 
8f052d9
2eba408
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13

import streamlit as st
from transformers import pipeline
from PIL import image

caption=pipeline('Image-to-text',model='ydshieh/vit-gpt2-coco-en')
uploaded_image=st.file.uploader("upload an image", type=["png","jpg","jpeg"])
if uploaded_image is not None:
    image=image.open(uploaded_image)
    st.image(image, caption="uploaded_image", use_column_width=True)
    if st.button("Generate caption"):
        captions=caption(image)
        st.write(captions[0],['generated text'])