Spaces:
Runtime error
Runtime error
| # Author: Ricardo Lisboa Santos | |
| # Creation date: 2024-01-10 | |
| import streamlit as st | |
| import time | |
| import AI.summarization as ai | |
| def run(): | |
| st.set_page_config(page_title="Summarization", page_icon="π") | |
| # setSidebar() | |
| # st.write('Summarization') | |
| st.markdown("# Summarization") | |
| input = st.text_area('Enter your LOOOONG text here.') | |
| if st.button('Click me to run'): | |
| progress_bar = st.sidebar.progress(0) | |
| status_text = st.sidebar.empty() | |
| loading_text='Loading Model' | |
| with st.spinner(text=loading_text): | |
| status_text.text("Getting Device") | |
| device = ai.getDevice("cpu") | |
| progress_bar.progress(30) | |
| status_text.text("Loading Model") | |
| model = ai.loadSummarizer(device) | |
| progress_bar.progress(60) | |
| status_text.text("Summarizing") | |
| output = ai.summarize(model, input) | |
| progress_bar.progress(90) | |
| ai.clearCache("cpu", model) | |
| progress_bar.progress(100) | |
| status_text.text("Done") | |
| st.code(output[0].get('summary_text')) | |
| if __name__ == '__main__': | |
| run() |