Spaces:
Running
Running
File size: 1,020 Bytes
94de7c5 f9714b1 94de7c5 f9714b1 94de7c5 cd5d153 94de7c5 f9714b1 94de7c5 3b08189 94de7c5 c9ab972 |
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 |
import streamlit as st
import streamlit.components.v1 as components
from infer_intent import IntentClassifier
from infer_location import LocationFinder
import matplotlib.pyplot as plt
st.title("Intent classifier")
@st.cache_resource
def get_intent_classifier():
cls = IntentClassifier()
return cls
@st.cache_resource
def get_location_finder():
ner = LocationFinder()
return ner
cls = get_intent_classifier()
query = st.text_input("Enter a query", value="What is the weather today")
query = query.lower()
pred_result, proba_result = cls.find_intent(query)
ner = get_location_finder()
location = ner.find_location(query)
st.markdown(f"Intent = :green[{pred_result}]")
st.markdown(f"Location = :green[{location}]")
keys = list(proba_result.keys())
values = list(proba_result.values())
# Creating the bar plot
fig, ax = plt.subplots()
ax.barh(keys, values)
# Adding labels and title
ax.set_xlabel('probability score')
ax.set_ylabel('Intents')
ax.set_title('Intents probability score')
st.pyplot(fig)
|