DawnC commited on
Commit
0f87b7e
·
verified ·
1 Parent(s): ac7b808

Update object_description_generator.py

Browse files
Files changed (1) hide show
  1. object_description_generator.py +15 -15
object_description_generator.py CHANGED
@@ -514,10 +514,10 @@ class ObjectDescriptionGenerator:
514
  confident_objects = [obj for obj in detected_objects
515
  if obj.get("confidence", 0) >= self.confidence_threshold_for_description]
516
 
517
- print(f"DEBUG: After confidence filtering (threshold={self.confidence_threshold_for_description}):")
518
- for class_name in ["car", "traffic light", "person", "handbag"]:
519
- class_objects = [obj for obj in confident_objects if obj.get("class_name") == class_name]
520
- print(f"DEBUG: {class_name}: {len(class_objects)} confident objects")
521
 
522
  if not confident_objects:
523
  no_confident_obj_msg = "While some elements might be present, no objects were identified with sufficient confidence for a detailed description."
@@ -557,10 +557,10 @@ class ObjectDescriptionGenerator:
557
  if name not in objects_by_class:
558
  objects_by_class[name] = []
559
  objects_by_class[name].append(obj)
560
- print(f"DEBUG: Before spatial deduplication:")
561
- for class_name in ["car", "traffic light", "person", "handbag"]:
562
- if class_name in objects_by_class:
563
- print(f"DEBUG: {class_name}: {len(objects_by_class[class_name])} objects before dedup")
564
 
565
  if not objects_by_class:
566
  description_segments.append("No common objects were confidently identified for detailed description.")
@@ -617,10 +617,10 @@ class ObjectDescriptionGenerator:
617
 
618
  objects_by_class = deduplicated_objects_by_class
619
 
620
- print(f"DEBUG: After spatial deduplication:")
621
- for class_name in ["car", "traffic light", "person", "handbag"]:
622
- if class_name in objects_by_class:
623
- print(f"DEBUG: {class_name}: {len(objects_by_class[class_name])} objects after dedup")
624
 
625
  sorted_object_groups = sorted(objects_by_class.items(), key=sort_key_object_groups)
626
 
@@ -629,8 +629,8 @@ class ObjectDescriptionGenerator:
629
  for class_name, group_of_objects in sorted_object_groups:
630
  count = len(group_of_objects)
631
 
632
- if class_name in ["car", "traffic light", "person", "handbag"]:
633
- print(f"DEBUG: Final count for {class_name}: {count}")
634
 
635
  if count == 0:
636
  continue
@@ -1282,4 +1282,4 @@ class ObjectDescriptionGenerator:
1282
 
1283
  except Exception as e:
1284
  self.logger.error(f"Error updating configuration: {str(e)}")
1285
- raise ObjectDescriptionError(f"Failed to update configuration: {str(e)}") from e
 
514
  confident_objects = [obj for obj in detected_objects
515
  if obj.get("confidence", 0) >= self.confidence_threshold_for_description]
516
 
517
+ # print(f"DEBUG: After confidence filtering (threshold={self.confidence_threshold_for_description}):")
518
+ # for class_name in ["car", "traffic light", "person", "handbag"]:
519
+ # class_objects = [obj for obj in confident_objects if obj.get("class_name") == class_name]
520
+ # print(f"DEBUG: {class_name}: {len(class_objects)} confident objects")
521
 
522
  if not confident_objects:
523
  no_confident_obj_msg = "While some elements might be present, no objects were identified with sufficient confidence for a detailed description."
 
557
  if name not in objects_by_class:
558
  objects_by_class[name] = []
559
  objects_by_class[name].append(obj)
560
+ # print(f"DEBUG: Before spatial deduplication:")
561
+ # for class_name in ["car", "traffic light", "person", "handbag"]:
562
+ # if class_name in objects_by_class:
563
+ # print(f"DEBUG: {class_name}: {len(objects_by_class[class_name])} objects before dedup")
564
 
565
  if not objects_by_class:
566
  description_segments.append("No common objects were confidently identified for detailed description.")
 
617
 
618
  objects_by_class = deduplicated_objects_by_class
619
 
620
+ # print(f"DEBUG: After spatial deduplication:")
621
+ # for class_name in ["car", "traffic light", "person", "handbag"]:
622
+ # if class_name in objects_by_class:
623
+ # print(f"DEBUG: {class_name}: {len(objects_by_class[class_name])} objects after dedup")
624
 
625
  sorted_object_groups = sorted(objects_by_class.items(), key=sort_key_object_groups)
626
 
 
629
  for class_name, group_of_objects in sorted_object_groups:
630
  count = len(group_of_objects)
631
 
632
+ # if class_name in ["car", "traffic light", "person", "handbag"]:
633
+ # print(f"DEBUG: Final count for {class_name}: {count}")
634
 
635
  if count == 0:
636
  continue
 
1282
 
1283
  except Exception as e:
1284
  self.logger.error(f"Error updating configuration: {str(e)}")
1285
+ raise ObjectDescriptionError(f"Failed to update configuration: {str(e)}") from e