ychafiqui commited on
Commit
5357c74
1 Parent(s): b7e9fbb

fixed bug that clears selected parts to filter after validating annotation

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -10,18 +10,20 @@ car_map = declare_component("car_map", path="./car_map")
10
 
11
  if "reset" not in st.session_state:
12
  st.session_state["reset"] = False
 
 
13
 
14
  with st.sidebar:
15
  name = st.text_input("Name *", value=st.session_state.get("name", ""))
16
  name = name.strip().lower()
17
  name_error_placeholder = st.empty()
18
 
19
- parts_filter = st.multiselect("Filter images by damaged parts (optional)", get_car_parts_count(), help="Select one or more parts to filter the images by.")
20
-
21
  if st.button("Start annotation"):
22
  if name:
23
  st.session_state["name"] = name
24
- st.session_state["img"], st.session_state["img_name"] = get_random_image(parts_filter)
25
  st.rerun()
26
  else:
27
  name_error_placeholder.error("Name is required")
@@ -104,7 +106,7 @@ if "name" in st.session_state:
104
  st.session_state["prev_img_name"] = img_name
105
  st.session_state["prev_img"] = img
106
  st.session_state["prev_rotation"] = st.session_state["rotation"]
107
- st.session_state["img"], st.session_state["img_name"] = get_random_image(parts_filter)
108
  st.session_state["rotation"] = 0
109
  st.session_state["reset"] = False
110
  st.rerun()
 
10
 
11
  if "reset" not in st.session_state:
12
  st.session_state["reset"] = False
13
+ if "parts_filter" not in st.session_state:
14
+ st.session_state["parts_filter"] = []
15
 
16
  with st.sidebar:
17
  name = st.text_input("Name *", value=st.session_state.get("name", ""))
18
  name = name.strip().lower()
19
  name_error_placeholder = st.empty()
20
 
21
+ st.session_state["parts_filter"] = st.multiselect("Filter images by damaged parts (optional)", get_car_parts_count(), help="Select one or more parts to filter the images by.", default=st.session_state["parts_filter"])
22
+
23
  if st.button("Start annotation"):
24
  if name:
25
  st.session_state["name"] = name
26
+ st.session_state["img"], st.session_state["img_name"] = get_random_image(st.session_state["parts_filter"])
27
  st.rerun()
28
  else:
29
  name_error_placeholder.error("Name is required")
 
106
  st.session_state["prev_img_name"] = img_name
107
  st.session_state["prev_img"] = img
108
  st.session_state["prev_rotation"] = st.session_state["rotation"]
109
+ st.session_state["img"], st.session_state["img_name"] = get_random_image(st.session_state["parts_filter"])
110
  st.session_state["rotation"] = 0
111
  st.session_state["reset"] = False
112
  st.rerun()