Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +27 -20
src/streamlit_app.py
CHANGED
@@ -118,33 +118,40 @@ if not comet_initialized:
|
|
118 |
|
119 |
|
120 |
# --- Label Definitions ---
|
121 |
-
labels = [
|
122 |
-
"People",
|
123 |
-
"Locations",
|
124 |
-
|
125 |
-
"Organizations",
|
126 |
|
127 |
-
"Dates",
|
128 |
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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": ["
|
141 |
-
"
|
142 |
-
"
|
143 |
-
"
|
144 |
-
"
|
145 |
-
|
146 |
-
"Vehicles": ["Vehicles"],
|
147 |
-
"Numbers": ["Numbers"],
|
148 |
|
149 |
|
150 |
}
|
@@ -154,7 +161,7 @@ category_mapping = {
|
|
154 |
def load_ner_model():
|
155 |
"""Loads the GLiNER model and caches it."""
|
156 |
try:
|
157 |
-
return GLiNER.from_pretrained("EmergentMethods/
|
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()
|
|
|
118 |
|
119 |
|
120 |
# --- Label Definitions ---
|
|
|
|
|
|
|
|
|
|
|
121 |
|
|
|
122 |
|
123 |
+
labels = [
|
124 |
+
'person',
|
125 |
+
'organization',
|
126 |
+
'location',
|
127 |
+
'date',
|
128 |
+
'time',
|
129 |
+
'event',
|
130 |
+
'title',
|
131 |
+
'product',
|
132 |
+
'law',
|
133 |
+
'policy',
|
134 |
+
'work of art',
|
135 |
+
'geopolitical entity',
|
136 |
+
'number',
|
137 |
+
'cause of death',
|
138 |
+
'weapon',
|
139 |
+
'vehicle',
|
140 |
+
'facility',
|
141 |
+
'temporal expression',
|
142 |
+
]
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
|
|
|
146 |
# Create a mapping dictionary for labels to categories
|
147 |
category_mapping = {
|
148 |
|
149 |
+
"People & Groups": ["Person", "Organization", "Title"],
|
150 |
+
"Topics & Objects":["Event", "Product", "Law", "Policy", "Work of Art", "Weapon", "Vehicle"],
|
151 |
+
"Temporal": ["Date", "Time", "Temporal expression"],
|
152 |
+
"Locations": ["Location", "Geopolitical entity", "Facility"],
|
153 |
+
"Quantitative & Contextual": ["Number", "Cause of death"]
|
154 |
+
|
|
|
|
|
155 |
|
156 |
|
157 |
}
|
|
|
161 |
def load_ner_model():
|
162 |
"""Loads the GLiNER model and caches it."""
|
163 |
try:
|
164 |
+
return GLiNER.from_pretrained("EmergentMethods/gliner_medium_news-v2.1", nested_ner=True, num_gen_sequences=2, gen_constraints= labels, threshold = 0.70)
|
165 |
except Exception as e:
|
166 |
st.error(f"Failed to load NER model. Please check your internet connection or model availability: {e}")
|
167 |
st.stop()
|