import streamlit as st from transformers import pipeline from tqdm import tqdm import time st.set_page_config(page_title='📜✂️ Chat Summarizer 📄🔍') st.title('📜✂️ Chat Summarizer 📄🔍') st.write("Check out the full notebook [here](https://www.kaggle.com/code/nicoladisabato/pegasus-fine-tuning-for-text-summarization)") # Define available models and their corresponding names models = { "nicoladisabato/pegasus-samsum": "nicoladisabato/pegasus-samsum" } selected_model = st.selectbox("Select a model", list(models.keys())) predefined_text = """Alice: Hey, have you heard about the new movie coming out next week? Bob: Yes, I saw the trailer. It looks really exciting. Alice: I'm thinking of getting tickets for opening night. Are you interested? Bob: I'd love to, but I might be busy with work that night. Alice: Oh, that's a shame. It would have been fun to watch it together. Bob: Definitely! Let me know how the movie is after you watch it. Alice: Will do! I'm hoping it lives up to the hype. Bob: Fingers crossed! Enjoy the movie if you go. Alice: Thanks! I'll give you a spoiler-free review afterward. Bob: Looking forward to it. Have a great time! """ text = st.text_area("Enter your chat", value=predefined_text, height=250) button = st.button('Summarize') if button: progress_text = "Loading the pipeline. It will take a minute :)" spinner = st.spinner(progress_text) with spinner: pipe = pipeline("summarization", model="nicoladisabato/pegasus-samsum") progress_text = "Summarization in progress." with st.spinner(progress_text): out = pipe(text) st.json(out)