Spaces:
Build error
Build error
Commit ·
be4b1a8
1
Parent(s): 69ed437
created text_image file
Browse files- text_to_image.py +15 -0
text_to_image.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
# pipelines will help to load the model from huggingface
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
# load_dotenv(find_dotenv())
|
| 5 |
+
st.title("Image to text generation App 🕵️♂️")
|
| 6 |
+
|
| 7 |
+
uploaded_file = st.file_uploader("Choose a file..",type= ['png', 'jpg'])
|
| 8 |
+
if uploaded_file is not None:
|
| 9 |
+
up_image=uploaded_file.name
|
| 10 |
+
#st.image(up_image)
|
| 11 |
+
st.image(up_image,caption="Uploaded Image",use_column_width=True)
|
| 12 |
+
image_to_text=pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
|
| 13 |
+
text=image_to_text(up_image)[0]["generated_text"]
|
| 14 |
+
st.subheader(text)
|
| 15 |
+
# #return text
|