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.")