ChandraP12330 commited on
Commit
832b0c8
·
verified ·
1 Parent(s): 092fb24

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+ from PIL import Image
4
+
5
+ # Create the caption pipeline
6
+ initial_caption = pipeline('image-to-text', model="Salesforce/blip-image-captioning-large")
7
+
8
+ # Display the image using Streamlit
9
+ uploaded_image = st.file_uploader("Upload an image", type=["png", "jpg", "jpeg"])
10
+ if uploaded_image is not None:
11
+ image= Image.open(uploaded_image)
12
+ st.image(image, caption="Uploaded Image", use_column_width=True)
13
+
14
+ # Generate the caption
15
+ if st.button("Generate Caption"):
16
+ captions = initial_caption(image)
17
+ st.write(captions[0]['generated_text'])