Spaces:
Sleeping
Sleeping
import streamlit as st | |
import time | |
from utils import valid_url | |
from model import get_tidy_tab_t5, predict_model_t5 | |
from model import get_tidy_tab_pegasus, predict_model_pegasus | |
from model import load_model_bart, predict_model_bart | |
from loadhtml import get_content | |
## Site | |
st.title("Tab Recall Simplified π") | |
st.markdown("Condense your Browser Tabs into a few impactful words. - Inspired in Arc Max Browser") | |
# load model | |
# Sidebar | |
st.sidebar.caption("Tidy Tabs - Title") | |
user_input_url = st.sidebar.text_input('Enter your url:') | |
error_message_url = None | |
def load_tab(): | |
if(user_input_url): | |
# Error message state | |
if(error_message_url): | |
error_message_url.empty() | |
is_url_valid,url = valid_url(user_input_url) | |
if is_url_valid: | |
text, title = get_content(url) | |
if(text == ""): | |
print("error") | |
else: | |
with st.spinner('Wait for it...'): | |
st.sidebar.write(f'<title>: **{title}**') | |
time.sleep(1) | |
with st.spinner('Wait for it...'): | |
st.sidebar.write(f'T5-small: **{predict_model_t5(text)}**') | |
with st.spinner('Wait for it...'): | |
st.sidebar.write(f'Pegasus xsum: **{predict_model_pegasus(text)}**') | |
with st.spinner('Wait for it...'): | |
st.sidebar.write(f'Pegasus Bart: **{predict_model_bart(text)}**') | |
else: | |
error_message = st.sidebar.error(f'{text} is not a valid URL. Please enter a valid URL.') | |
button_clicked = st.sidebar.button("Load tab", on_click=load_tab()) | |
st.sidebar.divider() | |
with st.status("Loading models...", expanded=True, state="complete") as models: | |
st.write("Loading https://huggingface.co/wgcv/tidy-tab-model-t5-small") | |
get_tidy_tab_t5() | |
st.write("Loaded T5-Small...") | |
st.write("Loaded from https://huggingface.co/wgcv/tidy-tab-model-pegasus-xsum") | |
get_tidy_tab_pegasus() | |
st.write("Loaded Pegasus xsum...") | |
st.write("Loaded from https://huggingface.co/wgcv/tidy-tab-model-bart-large-cnn") | |
load_model_bart() | |
st.write("Loaded Pegasus Bart-Large...") | |
models.update(label="All models loaded!", state="complete", expanded=False) | |