Spaces:
Running
on
Zero
Running
on
Zero
Upload functional_zone_identifier.py
Browse files- functional_zone_identifier.py +64 -27
functional_zone_identifier.py
CHANGED
|
@@ -688,7 +688,7 @@ class FunctionalZoneIdentifier:
|
|
| 688 |
if not high_conf_objects:
|
| 689 |
high_conf_objects = detected_objects # 後備到所有物件
|
| 690 |
|
| 691 |
-
#
|
| 692 |
processed_objects = set() # 避免重複處理相同類型的物件
|
| 693 |
|
| 694 |
for obj in high_conf_objects[:3]: # 限制為前3個物件
|
|
@@ -788,7 +788,6 @@ class FunctionalZoneIdentifier:
|
|
| 788 |
區域描述字串
|
| 789 |
"""
|
| 790 |
try:
|
| 791 |
-
# 物件特定描述
|
| 792 |
descriptions = {
|
| 793 |
"bed": "Sleeping and rest area",
|
| 794 |
"sofa": "Seating and relaxation area",
|
|
@@ -797,10 +796,42 @@ class FunctionalZoneIdentifier:
|
|
| 797 |
"tv": "Entertainment and media area",
|
| 798 |
"laptop": "Work and computing area",
|
| 799 |
"potted plant": "Decorative and green space area",
|
| 800 |
-
"refrigerator": "Food storage and kitchen area",
|
| 801 |
"car": "Vehicle and transportation area",
|
| 802 |
"person": "Activity and social area"
|
| 803 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 804 |
|
| 805 |
return descriptions.get(class_name, f"Functional area with {class_name}")
|
| 806 |
|
|
@@ -899,30 +930,36 @@ class FunctionalZoneIdentifier:
|
|
| 899 |
"surfboard": "sports area",
|
| 900 |
"tennis racket": "sports area",
|
| 901 |
|
| 902 |
-
#
|
| 903 |
-
"bottle": "
|
| 904 |
-
"wine glass": "
|
| 905 |
-
"cup": "
|
| 906 |
-
"fork": "
|
| 907 |
-
"knife": "
|
| 908 |
-
"spoon": "
|
| 909 |
-
"bowl": "
|
| 910 |
-
"
|
| 911 |
-
|
| 912 |
-
|
| 913 |
-
"
|
| 914 |
-
"
|
| 915 |
-
"
|
| 916 |
-
"
|
| 917 |
-
"
|
| 918 |
-
"
|
| 919 |
-
"
|
| 920 |
-
"
|
| 921 |
-
"
|
| 922 |
-
"
|
| 923 |
-
|
| 924 |
-
|
| 925 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 926 |
"book": "miscellaneous area",
|
| 927 |
"clock": "miscellaneous area",
|
| 928 |
"vase": "decorative area",
|
|
|
|
| 688 |
if not high_conf_objects:
|
| 689 |
high_conf_objects = detected_objects # 後備到所有物件
|
| 690 |
|
| 691 |
+
# 根據個別重要物件創建區域
|
| 692 |
processed_objects = set() # 避免重複處理相同類型的物件
|
| 693 |
|
| 694 |
for obj in high_conf_objects[:3]: # 限制為前3個物件
|
|
|
|
| 788 |
區域描述字串
|
| 789 |
"""
|
| 790 |
try:
|
|
|
|
| 791 |
descriptions = {
|
| 792 |
"bed": "Sleeping and rest area",
|
| 793 |
"sofa": "Seating and relaxation area",
|
|
|
|
| 796 |
"tv": "Entertainment and media area",
|
| 797 |
"laptop": "Work and computing area",
|
| 798 |
"potted plant": "Decorative and green space area",
|
|
|
|
| 799 |
"car": "Vehicle and transportation area",
|
| 800 |
"person": "Activity and social area"
|
| 801 |
}
|
| 802 |
+
|
| 803 |
+
# 只有在明確的廚房場景中才使用廚房描述
|
| 804 |
+
kitchen_related_objects = ["refrigerator", "microwave", "oven", "sink", "dishwasher", "stove"]
|
| 805 |
+
|
| 806 |
+
if class_name in kitchen_related_objects:
|
| 807 |
+
# 檢查場景類型是否真的是廚房相關
|
| 808 |
+
kitchen_scene_types = ["kitchen", "professional_kitchen", "cooking_area"]
|
| 809 |
+
|
| 810 |
+
if scene_type in kitchen_scene_types:
|
| 811 |
+
# 只有在明確的廚房場景中才使用廚房描述
|
| 812 |
+
if class_name == "refrigerator":
|
| 813 |
+
descriptions[class_name] = "Food storage and kitchen area"
|
| 814 |
+
elif class_name == "microwave":
|
| 815 |
+
descriptions[class_name] = "Food preparation area"
|
| 816 |
+
elif class_name == "oven":
|
| 817 |
+
descriptions[class_name] = "Cooking area"
|
| 818 |
+
elif class_name == "sink":
|
| 819 |
+
descriptions[class_name] = "Washing and preparation area"
|
| 820 |
+
else:
|
| 821 |
+
descriptions[class_name] = "Kitchen appliance area"
|
| 822 |
+
else:
|
| 823 |
+
# === 修正:非廚房場景中的廚房物件使用中性描述 ===
|
| 824 |
+
# 在餐廳、客廳等場景中,即使檢測到這些物件也不使用廚房描述
|
| 825 |
+
if class_name == "refrigerator":
|
| 826 |
+
descriptions[class_name] = "Storage area"
|
| 827 |
+
elif class_name == "microwave":
|
| 828 |
+
descriptions[class_name] = "Appliance area"
|
| 829 |
+
elif class_name == "oven":
|
| 830 |
+
descriptions[class_name] = "Equipment area"
|
| 831 |
+
elif class_name == "sink":
|
| 832 |
+
descriptions[class_name] = "Utility area"
|
| 833 |
+
else:
|
| 834 |
+
descriptions[class_name] = "Equipment area"
|
| 835 |
|
| 836 |
return descriptions.get(class_name, f"Functional area with {class_name}")
|
| 837 |
|
|
|
|
| 930 |
"surfboard": "sports area",
|
| 931 |
"tennis racket": "sports area",
|
| 932 |
|
| 933 |
+
# 餐具與用餐相關物品重新歸類為 dining area
|
| 934 |
+
"bottle": "dining area",
|
| 935 |
+
"wine glass": "dining area",
|
| 936 |
+
"cup": "dining area",
|
| 937 |
+
"fork": "dining area",
|
| 938 |
+
"knife": "dining area",
|
| 939 |
+
"spoon": "dining area",
|
| 940 |
+
"bowl": "dining area",
|
| 941 |
+
"dining table": "dining area", # 確保 dining table 也歸類為 dining area
|
| 942 |
+
|
| 943 |
+
# 食品使用中性的 food area
|
| 944 |
+
"banana": "food area",
|
| 945 |
+
"apple": "food area",
|
| 946 |
+
"sandwich": "food area",
|
| 947 |
+
"orange": "food area",
|
| 948 |
+
"broccoli": "food area",
|
| 949 |
+
"carrot": "food area",
|
| 950 |
+
"hot dog": "food area",
|
| 951 |
+
"pizza": "food area",
|
| 952 |
+
"donut": "food area",
|
| 953 |
+
"cake": "food area",
|
| 954 |
+
|
| 955 |
+
# 只有在有明確的廚房設備才使用 kitchen area
|
| 956 |
+
"refrigerator": "kitchen appliance area",
|
| 957 |
+
"oven": "kitchen appliance area",
|
| 958 |
+
"microwave": "kitchen appliance area",
|
| 959 |
+
"toaster": "kitchen appliance area",
|
| 960 |
+
"sink": "kitchen appliance area",
|
| 961 |
+
|
| 962 |
+
# 其他物品
|
| 963 |
"book": "miscellaneous area",
|
| 964 |
"clock": "miscellaneous area",
|
| 965 |
"vase": "decorative area",
|