File size: 997 Bytes
f79013b 24eb986 f79013b 24eb986 |
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 |
import streamlit as st
from src.constants import SETTINGS
from src.utils import load_models, print_results
def main():
st.title(SETTINGS.title)
col1, col2 = st.columns(2)
with col1:
st.header('Model Selection')
model_selected = st.radio('Choose model', SETTINGS.models)
with col2:
st.header('Input text')
input_text = col2.text_area(
'Write or paste any text',
value=SETTINGS.sample_text,
height=150
)
if st.button('Analyze', type='primary') and input_text != '':
pipes = load_models()
pipe = pipes[model_selected]
with st.spinner('Analyzing text...'):
output = pipe(input_text)
st.subheader(f"{SETTINGS.task.replace('-', ' ').capitalize()} results")
if isinstance(output, dict):
output = [output]
for i, result in enumerate(output, 1):
print_results(result)
if __name__ == '__main__':
main() |