AIEcosystem commited on
Commit
78eee87
·
verified ·
1 Parent(s): af1fbd5

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. 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("FOODS", divider="gray")
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
- "Fruits Vegetables",
123
- "Lactose, Diary, Eggs, Cheese, Yoghurt",
124
- "Meat, Fish, Seafood",
125
- "Frozen, Prepared Meals",
126
- "Baking, Cooking",
127
- "Cereals, Grains, Canned, Seeds",
128
- "Breads",
129
- "Snacks, Pastries, Treats",
130
- "Frozen Desserts",
131
- "Hot Drinks, Chilled Drinks",
132
- "Alcoholic Drinks",
133
- "Spices, Sauces",
134
- "World Foods",
135
- "Dietary Restrictions, Health, Allergens, Lifestyle"
136
  ]
137
  # Create a mapping dictionary for labels to categories
138
  category_mapping = {
139
 
140
- "Fresh & Primary Ingredients": ["Fruits Vegetables", "Meat, Fish, Seafood", "Lactose, Diary, Eggs, Cheese, Yoghurt"],
141
- "Pantry & Staple Goods" :["Cereals, Grains, Canned, Seeds", "Breads", "Spices, Sauces", "Baking, Cooking"],
142
- "Prepared & Convenience Foods": ["Frozen, Prepared Meals", "Snacks, Pastries, Treats", "Frozen Desserts", "World Foods"],
143
- "Beverages": ["Alcoholic Drinks", "Alcoholic Drinks"],
144
- "Meta-Labels & Lifestyle": ["Dietary Restrictions, Health, Allergens, Lifestyle"]
 
 
 
 
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("empathyai/gliner_large-v2.5-groceries", nested_ner=True, num_gen_sequences=2, gen_constraints= labels, threshold = 0.70)
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()