Spaces:
Build error
Build error
File size: 1,255 Bytes
5f5708d d0836be 5f5708d d0836be da7d7c9 5f5708d 718b723 e3b5cd1 5f5708d 8cfb12d 5f5708d 718b723 5f5708d d4aca5d 5f5708d db11074 5c7286b 5f5708d | 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 | import streamlit as st
import fasttext
model_path = "model_fastext.bin"
# Load the FastText model
model = fasttext.load_model(model_path)
# Load the FastText model
if 'ctr_out' not in st.session_state:
st.session_state['ctr_out'] = ['','']
st.title("_Text classification Using Fastext_")
st.header("_write the description inside the box_")
input_des=st.text_area("Description :point_down:",placeholder = 'str ')
input_des = ' '.join(input_des.split('\n'))
input_des = input_des.strip()
Predict=st.button("Predict :point_up_2: ",help = "Press it to predict")
def output_pre(output):
label = output[0][0]
probability = output[1][0]
# Clean up label string for better visualization
label = label.replace('__label__', '').replace('[', ' [').replace(']', '] ')
# Display the result
return label,probability
if Predict:
output=model.predict(input_des)
st.session_state['ctr_out'] = output_pre(output)
Diagonis=st.button("Diagonised result :point_down: ",help = "Press it to show result")
if Diagonis:
st.subheader('_Predicted Related meshroot_:point_down: ')
st.write_stream("LABEL : ",st.session_state['ctr_out'][0])
st.write_stream("ACCURACY :",st.session_state['ctr_out'][1])
|