Raphaël Bournhonesque commited on
Commit
972d5bb
·
1 Parent(s): c055452
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -105,12 +105,11 @@ def run(barcode: str, min_threshold: float = 0.5):
105
  text = prediction["text"]
106
  filtered_entities = [e for e in entities if e["score"] >= min_threshold]
107
 
108
- if filtered_entities:
109
- st.divider()
110
- image_path = generate_image_path(barcode, image_id)
111
- image_url = f"https://static.openfoodfacts.org/images/products{image_path}"
112
- st.image(image_url)
113
- display_ner_tags(text, filtered_entities)
114
 
115
 
116
  query_params = st.experimental_get_query_params()
@@ -118,9 +117,10 @@ default_barcode = query_params["barcode"][0] if "barcode" in query_params else "
118
 
119
  st.title("Ingredient extraction demo")
120
  st.markdown(
121
- "This demo leverages the ingredient entity detection model, that takes the OCR text as input and predict ingredient lists."
 
122
  )
123
- barcode = st.text_input("barcode", help="Barcode of the product", value=default_barcode)
124
  threshold = st.number_input(
125
  "threshold",
126
  help="Minimum threshold for entity predictions",
 
105
  text = prediction["text"]
106
  filtered_entities = [e for e in entities if e["score"] >= min_threshold]
107
 
108
+ st.divider()
109
+ image_path = generate_image_path(barcode, image_id)
110
+ image_url = f"https://static.openfoodfacts.org/images/products{image_path}"
111
+ st.image(image_url)
112
+ display_ner_tags(text, filtered_entities)
 
113
 
114
 
115
  query_params = st.experimental_get_query_params()
 
117
 
118
  st.title("Ingredient extraction demo")
119
  st.markdown(
120
+ "This demo leverages the ingredient entity detection model, "
121
+ "that takes the OCR text as input and predict ingredient lists."
122
  )
123
+ barcode = st.text_input("barcode", help="Barcode of the product", value=default_barcode).strip()
124
  threshold = st.number_input(
125
  "threshold",
126
  help="Minimum threshold for entity predictions",