ychafiqui commited on
Commit
a8a7e6d
1 Parent(s): 1aff445

added count of car parts in filter

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. functions.py +6 -1
app.py CHANGED
@@ -16,7 +16,7 @@ with st.sidebar:
16
  name = name.strip().lower()
17
  name_error_placeholder = st.empty()
18
 
19
- parts_filter = st.multiselect("Filter images by damaged parts (optional)", df.columns[6:], help="Select one or more parts to filter the images by.")
20
 
21
  if st.button("Start annotation"):
22
  if 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:
functions.py CHANGED
@@ -15,11 +15,16 @@ folder = "car-damage-detection/scrappedImages/"
15
  csv_folder = "car-damage-detection/CSVs/"
16
  s3_df_path = csv_folder + "70k_old_annotations_fixed.csv"
17
  response = s3_client.get_object(Bucket=bucket_name, Key=s3_df_path)
18
- # df = pd.read_csv("CSVs/70k_old_annotations_fixed.csv", low_memory=False)
19
  with io.BytesIO(response['Body'].read()) as bio:
20
  df = pd.read_csv(bio, low_memory=False)
21
  df = df[df['s3_available'] == True]
22
 
 
 
 
 
 
 
23
  def get_random_image(parts_filter=False):
24
  not_validated_imgs = df[df["validated"] == False]["img_name"].tolist()
25
  if parts_filter:
 
15
  csv_folder = "car-damage-detection/CSVs/"
16
  s3_df_path = csv_folder + "70k_old_annotations_fixed.csv"
17
  response = s3_client.get_object(Bucket=bucket_name, Key=s3_df_path)
 
18
  with io.BytesIO(response['Body'].read()) as bio:
19
  df = pd.read_csv(bio, low_memory=False)
20
  df = df[df['s3_available'] == True]
21
 
22
+ def get_car_parts_count():
23
+ car_parts = df.columns[6:]
24
+ # create a dictionary with the count of each part, +1 for a part if value > 0
25
+ car_parts_count = {part: len(df[df[part] > 0]) for part in car_parts}
26
+ return [f"{part} ({count})" for part, count in car_parts_count.items()]
27
+
28
  def get_random_image(parts_filter=False):
29
  not_validated_imgs = df[df["validated"] == False]["img_name"].tolist()
30
  if parts_filter: