Spaces:
Runtime error
Runtime error
import streamlit as st | |
from transformers import pipeline | |
from PIL import Image | |
import easyocr | |
# ghjklkjhgfghj | |
pipe = pipeline("text2text-generation", model="google/flan-t5-base") | |
st.title("Text Classification Model") | |
uploaded_file = st.file_uploader("Upload an image:") | |
if uploaded_file is not None: | |
image = Image.open(uploaded_file) | |
ocr_reader = easyocr.Reader(['en']) | |
ocr_results = ocr_reader.readtext(image) | |
extracted_text = " ".join([res[1] for res in ocr_results]) | |
st.markdown("**Extracted text:**") | |
st.markdown(extracted_text) | |
explanation = pipe(extracted_text, max_length=100, do_sample=True)[0]["generated_text"] | |
st.markdown("**Explanation:**") | |
st.markdown(explanation) | |
else: | |
st.markdown("Please upload an image to extract text and get an explanation.") | |