Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +25 -21
src/streamlit_app.py
CHANGED
@@ -69,7 +69,7 @@ st.markdown(
|
|
69 |
# --- Page Configuration and UI Elements ---
|
70 |
st.set_page_config(layout="wide", page_title="Named Entity Recognition App")
|
71 |
|
72 |
-
st.subheader("
|
73 |
st.link_button("by nlpblogs", "https://nlpblogs.com", type="tertiary")
|
74 |
|
75 |
expander = st.expander("**Important notes on the ProductTag**")
|
@@ -119,29 +119,33 @@ if not comet_initialized:
|
|
119 |
|
120 |
# --- Label Definitions ---
|
121 |
labels = [
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
]
|
137 |
# Create a mapping dictionary for labels to categories
|
138 |
category_mapping = {
|
139 |
|
140 |
-
"
|
141 |
-
"
|
142 |
-
"
|
143 |
-
"
|
144 |
-
"
|
|
|
|
|
|
|
|
|
145 |
|
146 |
}
|
147 |
|
@@ -150,7 +154,7 @@ category_mapping = {
|
|
150 |
def load_ner_model():
|
151 |
"""Loads the GLiNER model and caches it."""
|
152 |
try:
|
153 |
-
return GLiNER.from_pretrained("
|
154 |
except Exception as e:
|
155 |
st.error(f"Failed to load NER model. Please check your internet connection or model availability: {e}")
|
156 |
st.stop()
|
|
|
69 |
# --- Page Configuration and UI Elements ---
|
70 |
st.set_page_config(layout="wide", page_title="Named Entity Recognition App")
|
71 |
|
72 |
+
st.subheader("newS", divider="gray")
|
73 |
st.link_button("by nlpblogs", "https://nlpblogs.com", type="tertiary")
|
74 |
|
75 |
expander = st.expander("**Important notes on the ProductTag**")
|
|
|
119 |
|
120 |
# --- Label Definitions ---
|
121 |
labels = [
|
122 |
+
"People",
|
123 |
+
"Locations",
|
124 |
+
|
125 |
+
"Organizations",
|
126 |
+
|
127 |
+
"Dates",
|
128 |
+
|
129 |
+
"Events",
|
130 |
+
|
131 |
+
"Facilities",
|
132 |
+
|
133 |
+
"Vehicles",
|
134 |
+
|
135 |
+
"Numbers"
|
136 |
]
|
137 |
# Create a mapping dictionary for labels to categories
|
138 |
category_mapping = {
|
139 |
|
140 |
+
"People": ["People"],
|
141 |
+
"Locations" :["Locations"],
|
142 |
+
"Organizations": ["Organizations"],
|
143 |
+
"Dates": ["Dates"],
|
144 |
+
"Events": ["Events"],
|
145 |
+
"Facilities": ["Facilities"],
|
146 |
+
"Vehicles": ["Vehicles"],
|
147 |
+
"Numbers": ["Numbers"],
|
148 |
+
|
149 |
|
150 |
}
|
151 |
|
|
|
154 |
def load_ner_model():
|
155 |
"""Loads the GLiNER model and caches it."""
|
156 |
try:
|
157 |
+
return GLiNER.from_pretrained("EmergentMethods/gliner_small_news-v2.1", nested_ner=True, num_gen_sequences=2, gen_constraints= labels, threshold = 0.70)
|
158 |
except Exception as e:
|
159 |
st.error(f"Failed to load NER model. Please check your internet connection or model availability: {e}")
|
160 |
st.stop()
|