|
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() |