import streamlit as st import requests import torch from transformers import pipeline from transformers import BartTokenizer, BartForConditionalGeneration # Replace with your Hugging Face model repository path model_repo_path = 'Muh113/Text-Summ' # Load the model and tokenizer model = BartForConditionalGeneration.from_pretrained(model_repo_path) tokenizer = BartTokenizer.from_pretrained(model_repo_path) # Initialize the summarization pipeline summarizer = pipeline('summarization', model=model,tokenizer=tokenizer) # Streamlit app layout st.title("Text Summarization App") # User input text_input = st.text_area("Enter text to summarize", height=300) # Summarize the text if st.button("Summarize"): if text_input: with st.spinner("Generating summary..."): try: summary = summarizer(text_input, max_length=150, min_length=30, do_sample=False) st.subheader("Summary") st.write(summary[0]['summary_text']) except Exception as e: st.error(f"Error during summarization: {e}") else: st.warning("Please enter some text to summarize.")