Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| from transformers import pipeline | |
| # Load the text summarization pipeline | |
| model3_p1 = pipeline("summarization", model="syndi-models/titlewave-t5-base") | |
| # Load the classification pipeline | |
| model_name2_p2 = "elozano/bert-base-cased-news-category" | |
| classifier = pipeline("text-classification", model=model_name2_p2, return_all_scores=True) | |
| # Streamlit app title | |
| st.title("Question Summarization and Classification") | |
| # Tab layout | |
| tab1, tab2 = st.tabs(["Question Summarization", "Question Classification"]) | |
| with tab1: | |
| st.header("Question Summarization") | |
| # Input text for summarization | |
| text_to_summarize = st.text_area("Enter question to summarize:", "") | |
| if st.button("Summarize"): | |
| # Perform text summarization | |
| summary = model3_p1(text_to_summarize, max_length=130, min_length=30, do_sample=False) | |
| # Display the summary result | |
| st.write("Summary:", summary[0]['summary_text']) | |
| with tab2: | |
| st.header("Question Classification") | |
| # Input text for news classification | |
| text_to_classify = st.text_area("Enter question title to classify:", "") | |
| if st.button("Classify"): | |
| # Perform question classification | |
| results = classifier(text_to_classify)[0] | |
| # Display the classification result | |
| max_score = float('-inf') | |
| max_label = '' | |
| for result in results: | |
| if result['score'] > max_score: | |
| max_score = result['score'] | |
| max_label = result['label'] | |
| st.write("Text:", text_to_classify) | |
| st.write("Category:", max_label) | |
| st.write("Score:", max_score) |