cfc-tech's picture
u
27669e2 verified
raw
history blame
944 Bytes
import streamlit as st
from transformers import pipeline, logging
# Suppress warnings from transformers
logging.set_verbosity_error()
# Streamlit interface setup
st.title("Summarization Test")
# Initialize the summarizer
summarizer = pipeline("summarization")
# Test summarization with a hardcoded string
test_text = "This is a simple test sentence to verify the functionality of the summarization pipeline. The goal is to ensure that the pipeline can process input text correctly and produce a summary without encountering the input type error."
if st.button('Test Summarization'):
try:
# Attempt to summarize the hardcoded test text
summary = summarizer(test_text, max_length=130, min_length=30, do_sample=False)
st.success("Summarization succeeded!")
st.write("### Summary:")
st.write(summary[0]['summary_text'])
except Exception as e:
st.error(f"Summarization test failed: {e}")