Raphaël Bournhonesque commited on
Commit
62be7f8
·
1 Parent(s): 4123d5a

update after API breaking change

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -1,11 +1,10 @@
1
  import copy
2
- import pandas as pd
3
  from typing import Optional
4
 
 
5
  import requests
6
  import streamlit as st
7
 
8
-
9
  http_session = requests.Session()
10
 
11
  LOCAL_DB = False
@@ -20,7 +19,7 @@ PREDICTION_URL = ROBOTOFF_BASE_URL + "/predict/category"
20
 
21
  @st.cache_data
22
  def get_predictions(barcode: str, threshold: Optional[float] = None):
23
- data = {"barcode": barcode, "predictors": ["neural"]}
24
  if threshold is not None:
25
  data["threshold"] = threshold
26
 
@@ -28,6 +27,7 @@ def get_predictions(barcode: str, threshold: Optional[float] = None):
28
  r.raise_for_status()
29
  return r.json()["neural"]
30
 
 
31
  def display_predictions(
32
  barcode: str,
33
  threshold: Optional[float] = None,
@@ -40,20 +40,17 @@ def display_predictions(
40
  debug = response["debug"]
41
  response.pop("debug")
42
  st.write(pd.DataFrame(response["predictions"]))
43
-
44
  if debug is not None:
45
  st.markdown("**Debug information**")
46
  st.write(debug)
47
 
48
 
49
-
50
  st.sidebar.title("Category Prediction Demo")
51
  query_params = st.experimental_get_query_params()
52
 
53
  default_barcode = query_params["barcode"][0] if "barcode" in query_params else ""
54
- barcode = st.sidebar.text_input(
55
- "Product barcode", default_barcode
56
- )
57
  threshold = st.sidebar.number_input("Threshold", format="%f", value=0.5) or None
58
 
59
  if barcode:
 
1
  import copy
 
2
  from typing import Optional
3
 
4
+ import pandas as pd
5
  import requests
6
  import streamlit as st
7
 
 
8
  http_session = requests.Session()
9
 
10
  LOCAL_DB = False
 
19
 
20
  @st.cache_data
21
  def get_predictions(barcode: str, threshold: Optional[float] = None):
22
+ data = {"barcode": barcode}
23
  if threshold is not None:
24
  data["threshold"] = threshold
25
 
 
27
  r.raise_for_status()
28
  return r.json()["neural"]
29
 
30
+
31
  def display_predictions(
32
  barcode: str,
33
  threshold: Optional[float] = None,
 
40
  debug = response["debug"]
41
  response.pop("debug")
42
  st.write(pd.DataFrame(response["predictions"]))
43
+
44
  if debug is not None:
45
  st.markdown("**Debug information**")
46
  st.write(debug)
47
 
48
 
 
49
  st.sidebar.title("Category Prediction Demo")
50
  query_params = st.experimental_get_query_params()
51
 
52
  default_barcode = query_params["barcode"][0] if "barcode" in query_params else ""
53
+ barcode = st.sidebar.text_input("Product barcode", default_barcode)
 
 
54
  threshold = st.sidebar.number_input("Threshold", format="%f", value=0.5) or None
55
 
56
  if barcode: