Spaces:
Runtime error
Runtime error
File size: 917 Bytes
5454af5 6d8a5b6 5454af5 6d8a5b6 4ae8bae 75e4b7c 15d18c4 3c97a0a 15d18c4 6d8a5b6 79be51e 6d8a5b6 d45b0ff 75e4b7c 15d18c4 75e4b7c c9e5fc0 6d8a5b6 313c320 15d18c4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import streamlit as st
from transformers import pipeline
# Create a text2text-generation pipeline
pipe = pipeline("text2text-generation", model="kaist-ai/prometheus-13b-v1.0")
st.title("Text Classification Model")
uploaded_file = st.file_uploader("Upload an image:")
if uploaded_file is not None:
# Read the uploaded image
image = Image.open(uploaded_file)
# Extract text from the image using OCR
ocr_results = extract_text(image)
extracted_text = " ".join([res[1] for res in ocr_results])
st.markdown("**Extracted text:**")
st.markdown(extracted_text)
# Generate an explanation for the extracted text using the Hugging Face pipeline
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.")
|