DawnC commited on
Commit
bb00c19
·
verified ·
1 Parent(s): be82503

Update object_description_generator.py

Browse files
Files changed (1) hide show
  1. object_description_generator.py +19 -0
object_description_generator.py CHANGED
@@ -513,6 +513,11 @@ class ObjectDescriptionGenerator:
513
  # 使用置信度過濾
514
  confident_objects = [obj for obj in detected_objects
515
  if obj.get("confidence", 0) >= self.confidence_threshold_for_description]
 
 
 
 
 
516
 
517
  if not confident_objects:
518
  no_confident_obj_msg = "While some elements might be present, no objects were identified with sufficient confidence for a detailed description."
@@ -552,6 +557,10 @@ class ObjectDescriptionGenerator:
552
  if name not in objects_by_class:
553
  objects_by_class[name] = []
554
  objects_by_class[name].append(obj)
 
 
 
 
555
 
556
  if not objects_by_class:
557
  description_segments.append("No common objects were confidently identified for detailed description.")
@@ -607,12 +616,22 @@ class ObjectDescriptionGenerator:
607
  deduplicated_objects_by_class[class_name] = unique_objects
608
 
609
  objects_by_class = deduplicated_objects_by_class
 
 
 
 
 
 
610
  sorted_object_groups = sorted(objects_by_class.items(), key=sort_key_object_groups)
611
 
612
  object_clauses = []
613
 
614
  for class_name, group_of_objects in sorted_object_groups:
615
  count = len(group_of_objects)
 
 
 
 
616
  if count == 0:
617
  continue
618
 
 
513
  # 使用置信度過濾
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.")
 
616
  deduplicated_objects_by_class[class_name] = unique_objects
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
 
627
  object_clauses = []
628
 
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
637