File size: 1,605 Bytes
e276af2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
import streamlit as st
mapper = {
"wikilingua": "64b53c9e04b2bfaeb2f0b38cb7712bcbd4755c3f",
"vietnews": "d8d516ad2c112b429155c3e6077182ae5fe5b33d"
}
if "model" not in st.session_state:
from src.model import Model
st.session_state.task="wikilingua"
model = Model(revision=mapper["wikilingua"])
st.session_state.model = model
st.set_page_config(page_title="ViT5 Reproduce", layout="wide")
hide_menu_style = """
<style>
footer {visibility: hidden;}
</style>
"""
st.markdown(hide_menu_style, unsafe_allow_html= True)
with st.sidebar:
task = st.selectbox(label="Task", options=["wikilingua", "vietnews"])
if task != st.session_state.task:
from src.model import Model
st.session_state.task=task
model = Model(revision=mapper[task])
left, middle, right = st.columns([4,1,4])
left_container = left.container(border=True)
left_container.write(f"**Input**")
left_container.divider()
text = left_container.text_area(label="", height=512, label_visibility="hidden", max_chars=4096*5)
summary_button = middle.button("Summary ➩", type="primary", use_container_width=True)
right_container = right.container(border=True)
right_container.markdown(f"**Output**")
right_container.divider()
if summary_button:
output = st.session_state.model.inference(text=text)
st.session_state["output"] = output
if "output" in st.session_state:
right_container.text_area(label="", value=st.session_state["output"], height=512, label_visibility="hidden")
|