test-B / app.py
avreymi's picture
change run
372c8e4
from t5 import t5
import torch
import streamlit as st
from streamlit import session_state as ses
import timeit
import random
text_list = "Prospecting Academy is a 6 weeks online course designed for business owners, marketing and sales leaders of B2B scaleup companies to help you".split()
def random_sentence():
return " ".join(
list(random.choice(text_list) for i in range(random.randint(4, 20)))
)
if "page" not in ses:
ses["page"] = "run"
ses.out = ""
ses.time = ""
def __run_t5():
try:
ses.out = t5(ses.input_text)
except:
ses.out = "error"
def __test_t5():
try:
ses.time = timeit.timeit("t5(random_sentence())", globals=globals(), number=20)
except:
ses.out = "error"
st.text_input("enter text", key="input_text", on_change=__run_t5)
st.write(ses.out)
if st.button("average time", on_click=__test_t5):
st.metric("time", ses.time)