Spaces:
Build error
Build error
Download app.py from chandanrajCL/fasttextclassification: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/spaces/chandanrajCL/fasttextclassification/resolve/main/app.py
- Command line
-
hf download hf://spaces/chandanrajCL/fasttextclassification/app.py
-
curl -L -o app.py https://huggingface.co/spaces/chandanrajCL/fasttextclassification/resolve/main/app.py
1.26 kB
| 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]) | |