Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
from io import BytesIO
|
|
|
4 |
import torch
|
5 |
|
6 |
# Load pipelines
|
@@ -13,11 +14,11 @@ st.title("Image-to-Text and Text-to-Speech App")
|
|
13 |
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "png", "jpeg"])
|
14 |
|
15 |
if uploaded_image:
|
16 |
-
|
|
|
17 |
|
18 |
# Convert image to text
|
19 |
-
|
20 |
-
text_output = image_to_text(image_bytes)[0]['generated_text']
|
21 |
st.write("### Extracted Text:")
|
22 |
st.write(text_output)
|
23 |
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
from io import BytesIO
|
4 |
+
from PIL import Image
|
5 |
import torch
|
6 |
|
7 |
# Load pipelines
|
|
|
14 |
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "png", "jpeg"])
|
15 |
|
16 |
if uploaded_image:
|
17 |
+
image = Image.open(uploaded_image)
|
18 |
+
st.image(image, caption="Uploaded Image", use_container_width=True)
|
19 |
|
20 |
# Convert image to text
|
21 |
+
text_output = image_to_text(image)[0]['generated_text']
|
|
|
22 |
st.write("### Extracted Text:")
|
23 |
st.write(text_output)
|
24 |
|