guqing 6 روز پیش
والد
کامیت
7c35def4f2
39فایلهای تغییر یافته به همراه6607 افزوده شده و 0 حذف شده
  1. 3 0
      depoly_cultural relics and furniture/.idea/.gitignore
  2. 12 0
      depoly_cultural relics and furniture/.idea/depoly.iml
  3. 56 0
      depoly_cultural relics and furniture/.idea/inspectionProfiles/Project_Default.xml
  4. 6 0
      depoly_cultural relics and furniture/.idea/inspectionProfiles/profiles_settings.xml
  5. 4 0
      depoly_cultural relics and furniture/.idea/misc.xml
  6. 8 0
      depoly_cultural relics and furniture/.idea/modules.xml
  7. 13 0
      depoly_cultural relics and furniture/depoly.txt
  8. 24 0
      depoly_cultural relics and furniture/inf_run.txt
  9. BIN
      depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/SG-0uQb047fxOJ_0.jpg
  10. BIN
      depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/__pycache__/obb_client.cpython-38-pytest-8.3.5.pyc
  11. BIN
      depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/__pycache__/obb_server.cpython-312.pyc
  12. BIN
      depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/__pycache__/obb_server.cpython-38.pyc
  13. 12 0
      depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/load_result_json.py
  14. 104 0
      depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/nohup.out
  15. BIN
      depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/nolabel.jpg
  16. 105 0
      depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/obb_client.py
  17. 111 0
      depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/obb_client_cpu.py
  18. BIN
      depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/obb_detect_Cultural relics disease detection-2560.pt
  19. 218 0
      depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/obb_results.json
  20. 158 0
      depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/obb_server.py
  21. BIN
      depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/res_SG-0uQb047fxOJ_0.jpg
  22. 218 0
      depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/res_SG-0uQb047fxOJ_0.json
  23. BIN
      depoly_cultural relics and furniture/seg_detect_Panoramic_Home/KJ-vYL6GFH2fYw_30.jpg
  24. BIN
      depoly_cultural relics and furniture/seg_detect_Panoramic_Home/__pycache__/obb_client.cpython-38-pytest-8.3.5.pyc
  25. BIN
      depoly_cultural relics and furniture/seg_detect_Panoramic_Home/__pycache__/seg_client.cpython-38-pytest-8.3.5.pyc
  26. BIN
      depoly_cultural relics and furniture/seg_detect_Panoramic_Home/__pycache__/seg_server.cpython-312.pyc
  27. BIN
      depoly_cultural relics and furniture/seg_detect_Panoramic_Home/__pycache__/seg_server.cpython-38.pyc
  28. 12 0
      depoly_cultural relics and furniture/seg_detect_Panoramic_Home/load_result_json.py
  29. 4234 0
      depoly_cultural relics and furniture/seg_detect_Panoramic_Home/nohup.out
  30. BIN
      depoly_cultural relics and furniture/seg_detect_Panoramic_Home/nolabel.jpg
  31. BIN
      depoly_cultural relics and furniture/seg_detect_Panoramic_Home/res_KJ-vYL6GFH2fYw_30.jpg
  32. 315 0
      depoly_cultural relics and furniture/seg_detect_Panoramic_Home/res_KJ-vYL6GFH2fYw_30.json
  33. 120 0
      depoly_cultural relics and furniture/seg_detect_Panoramic_Home/seg_client.py
  34. 103 0
      depoly_cultural relics and furniture/seg_detect_Panoramic_Home/seg_client_cpu.py
  35. BIN
      depoly_cultural relics and furniture/seg_detect_Panoramic_Home/seg_detect_Panoramic_Home.pt
  36. 315 0
      depoly_cultural relics and furniture/seg_detect_Panoramic_Home/seg_results.json
  37. 205 0
      depoly_cultural relics and furniture/seg_detect_Panoramic_Home/seg_server.py
  38. 202 0
      depoly_cultural relics and furniture/seg_detect_Panoramic_Home/server_copy.py
  39. 49 0
      depoly_cultural relics and furniture/seg_detect_Panoramic_Home/yolov_seg_test.py

+ 3 - 0
depoly_cultural relics and furniture/.idea/.gitignore

@@ -0,0 +1,3 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml

+ 12 - 0
depoly_cultural relics and furniture/.idea/depoly.iml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="PYTHON_MODULE" version="4">
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="jdk" jdkName="yolo11 (3)" jdkType="Python SDK" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+  <component name="PyDocumentationSettings">
+    <option name="format" value="PLAIN" />
+    <option name="myDocStringFormat" value="Plain" />
+  </component>
+</module>

+ 56 - 0
depoly_cultural relics and furniture/.idea/inspectionProfiles/Project_Default.xml

@@ -0,0 +1,56 @@
+<component name="InspectionProjectProfileManager">
+  <profile version="1.0">
+    <option name="myName" value="Project Default" />
+    <inspection_tool class="PyPackageRequirementsInspection" enabled="false" level="WARNING" enabled_by_default="false">
+      <option name="ignoredPackages">
+        <value>
+          <list size="43">
+            <item index="0" class="java.lang.String" itemvalue="scikit-image" />
+            <item index="1" class="java.lang.String" itemvalue="paddlepaddle" />
+            <item index="2" class="java.lang.String" itemvalue="gradio" />
+            <item index="3" class="java.lang.String" itemvalue="pillow" />
+            <item index="4" class="java.lang.String" itemvalue="numpy" />
+            <item index="5" class="java.lang.String" itemvalue="paddlehub" />
+            <item index="6" class="java.lang.String" itemvalue="onnxruntime-gpu" />
+            <item index="7" class="java.lang.String" itemvalue="onnxslim" />
+            <item index="8" class="java.lang.String" itemvalue="onnxscript" />
+            <item index="9" class="java.lang.String" itemvalue="tqdm" />
+            <item index="10" class="java.lang.String" itemvalue="openai" />
+            <item index="11" class="java.lang.String" itemvalue="edge_tts" />
+            <item index="12" class="java.lang.String" itemvalue="diffusers" />
+            <item index="13" class="java.lang.String" itemvalue="torch" />
+            <item index="14" class="java.lang.String" itemvalue="tensorflow" />
+            <item index="15" class="java.lang.String" itemvalue="pyaml" />
+            <item index="16" class="java.lang.String" itemvalue="h5py" />
+            <item index="17" class="java.lang.String" itemvalue="PyYAML" />
+            <item index="18" class="java.lang.String" itemvalue="xformers" />
+            <item index="19" class="java.lang.String" itemvalue="torchvision" />
+            <item index="20" class="java.lang.String" itemvalue="lmdb" />
+            <item index="21" class="java.lang.String" itemvalue="Requests" />
+            <item index="22" class="java.lang.String" itemvalue="safetensors" />
+            <item index="23" class="java.lang.String" itemvalue="mc" />
+            <item index="24" class="java.lang.String" itemvalue="wandb" />
+            <item index="25" class="java.lang.String" itemvalue="accelerate" />
+            <item index="26" class="java.lang.String" itemvalue="tensorflow_io" />
+            <item index="27" class="java.lang.String" itemvalue="typed_argument_parser" />
+            <item index="28" class="java.lang.String" itemvalue="flash_attn" />
+            <item index="29" class="java.lang.String" itemvalue="huggingface_hub" />
+            <item index="30" class="java.lang.String" itemvalue="opencv_python" />
+            <item index="31" class="java.lang.String" itemvalue="scipy" />
+            <item index="32" class="java.lang.String" itemvalue="transformers" />
+            <item index="33" class="java.lang.String" itemvalue="opencv_python_headless" />
+            <item index="34" class="java.lang.String" itemvalue="modules" />
+            <item index="35" class="java.lang.String" itemvalue="pandas" />
+            <item index="36" class="java.lang.String" itemvalue="pyiqa" />
+            <item index="37" class="java.lang.String" itemvalue="tensorboard" />
+            <item index="38" class="java.lang.String" itemvalue="imageio" />
+            <item index="39" class="java.lang.String" itemvalue="pytz" />
+            <item index="40" class="java.lang.String" itemvalue="einops" />
+            <item index="41" class="java.lang.String" itemvalue="skimage" />
+            <item index="42" class="java.lang.String" itemvalue="Pillow" />
+          </list>
+        </value>
+      </option>
+    </inspection_tool>
+  </profile>
+</component>

+ 6 - 0
depoly_cultural relics and furniture/.idea/inspectionProfiles/profiles_settings.xml

@@ -0,0 +1,6 @@
+<component name="InspectionProjectProfileManager">
+  <settings>
+    <option name="USE_PROJECT_PROFILE" value="false" />
+    <version value="1.0" />
+  </settings>
+</component>

+ 4 - 0
depoly_cultural relics and furniture/.idea/misc.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectRootManager" version="2" project-jdk-name="yolo11 (3)" project-jdk-type="Python SDK" />
+</project>

+ 8 - 0
depoly_cultural relics and furniture/.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/depoly.iml" filepath="$PROJECT_DIR$/.idea/depoly.iml" />
+    </modules>
+  </component>
+</project>

+ 13 - 0
depoly_cultural relics and furniture/depoly.txt

@@ -0,0 +1,13 @@
+python 3.8.20
+
+io
+PIL
+fastapi
+ultralytics
+contextlib
+base64
+json
+os
+uvicorn
+requests
+argparse

+ 24 - 0
depoly_cultural relics and furniture/inf_run.txt

@@ -0,0 +1,24 @@
+###################################################
+文物病害检测
+
+cd obb_detect_Cultural relics disease detection
+
+#run the server
+python obb_server.py
+
+#run the client
+python obb_client_cpu.py -i 图片名称
+###################################################
+
+
+###################################################
+全景图中家具检测
+
+cd seg_detect_Panoramic_Home
+
+#run the server
+python seg_server.py
+
+#run the client
+python seg_client_cpu.py -i 图片名称
+###################################################

BIN
depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/SG-0uQb047fxOJ_0.jpg


BIN
depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/__pycache__/obb_client.cpython-38-pytest-8.3.5.pyc


BIN
depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/__pycache__/obb_server.cpython-312.pyc


BIN
depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/__pycache__/obb_server.cpython-38.pyc


+ 12 - 0
depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/load_result_json.py

@@ -0,0 +1,12 @@
+import json
+import cv2
+import numpy as np
+# 读取JSON文件
+with open("obb_results.json", "r", encoding="utf-8") as f:
+    obb_inf = json.load(f)  # 解析为Python字典/列表
+    img = cv2.imread(obb_inf['imagePath'])
+    obb_lists = obb_inf['shapes']
+    for obb in (obb_lists):
+        bbox = [np.array(obb['bbox']).reshape((-1, 2)).astype(np.int32)]
+        cv2.polylines(img, bbox, True, (0, 0, 255), thickness=4, lineType=cv2.LINE_8, shift=0)
+cv2.imwrite('output.png', img)

+ 104 - 0
depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/nohup.out

@@ -0,0 +1,104 @@
+INFO:     Will watch for changes in these directories: ['/home/dage/guqing/depoly/yolov11_depoly/depoly/obb_detect_Cultural relics disease detection']
+INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
+INFO:     Started reloader process [13806] using StatReload
+INFO:     Started server process [13808]
+INFO:     Waiting for application startup.
+INFO:     Application startup complete.
+WARNING:  StatReload detected changes in 'obb_client.py'. Reloading...
+INFO:     Shutting down
+INFO:     Waiting for application shutdown.
+INFO:     Application shutdown complete.
+INFO:     Finished server process [13808]
+INFO:     Started server process [13865]
+INFO:     Waiting for application startup.
+INFO:     Application startup complete.
+应用启动...开始加载模型...
+模型加载完成!
+
+0: 320x640 (no detections), 35.6ms
+Speed: 1.9ms preprocess, 35.6ms inference, 7.6ms postprocess per image at shape (1, 3, 320, 640)
+INFO:     192.168.9.113:33124 - "POST /obb HTTP/1.1" 200 OK
+WARNING:  StatReload detected changes in 'obb_server.py'. Reloading...
+INFO:     Shutting down
+INFO:     Waiting for application shutdown.
+INFO:     Application shutdown complete.
+INFO:     Finished server process [13865]
+INFO:     Started server process [13938]
+INFO:     Waiting for application startup.
+INFO:     Application startup complete.
+应用启动...开始加载模型...
+模型加载完成!
+
+0: 1280x2560 1 破损与剥落, 2 微生物侵害s, 7 渗水s, 97.0ms
+Speed: 10.4ms preprocess, 97.0ms inference, 77.6ms postprocess per image at shape (1, 3, 1280, 2560)
+INFO:     192.168.9.113:55116 - "POST /obb HTTP/1.1" 200 OK
+
+0: 1280x2560 1 破损与剥落, 2 微生物侵害s, 7 渗水s, 96.9ms
+Speed: 30.7ms preprocess, 96.9ms inference, 1.1ms postprocess per image at shape (1, 3, 1280, 2560)
+INFO:     192.168.9.52:35596 - "POST /obb HTTP/1.1" 200 OK
+
+0: 1280x2560 1 破损与剥落, 2 微生物侵害s, 7 渗水s, 97.0ms
+Speed: 31.7ms preprocess, 97.0ms inference, 0.9ms postprocess per image at shape (1, 3, 1280, 2560)
+INFO:     192.168.0.17:14256 - "POST /obb HTTP/1.1" 200 OK
+
+0: 1280x2560 1 破损与剥落, 2 微生物侵害s, 7 渗水s, 117.8ms
+Speed: 29.1ms preprocess, 117.8ms inference, 1.3ms postprocess per image at shape (1, 3, 1280, 2560)
+INFO:     192.168.0.17:13569 - "POST /obb HTTP/1.1" 200 OK
+
+0: 1280x2560 1 破损与剥落, 2 微生物侵害s, 7 渗水s, 97.0ms
+Speed: 28.0ms preprocess, 97.0ms inference, 0.9ms postprocess per image at shape (1, 3, 1280, 2560)
+INFO:     172.23.0.11:49300 - "POST /obb HTTP/1.1" 200 OK
+INFO:     Will watch for changes in these directories: ['/home/dage/guqing/depoly/yolov11_depoly/depoly/obb_detect_Cultural relics disease detection']
+ERROR:    [Errno 98] Address already in use
+INFO:     Will watch for changes in these directories: ['/home/dage/guqing/depoly/yolov11_depoly/depoly/obb_detect_Cultural relics disease detection']
+INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
+INFO:     Started reloader process [3961003] using StatReload
+INFO:     Started server process [3961027]
+INFO:     Waiting for application startup.
+INFO:     Application startup complete.
+应用启动...开始加载模型...
+模型加载完成!
+
+0: 1280x2560 1 破损与剥落, 2 微生物侵害s, 7 渗水s, 97.7ms
+Speed: 11.4ms preprocess, 97.7ms inference, 78.2ms postprocess per image at shape (1, 3, 1280, 2560)
+INFO:     192.168.9.52:54558 - "POST /obb HTTP/1.1" 200 OK
+
+0: 1280x2560 1 破损与剥落, 2 微生物侵害s, 7 渗水s, 101.4ms
+Speed: 29.0ms preprocess, 101.4ms inference, 1.0ms postprocess per image at shape (1, 3, 1280, 2560)
+INFO:     192.168.9.52:42908 - "POST /obb HTTP/1.1" 200 OK
+WARNING:  StatReload detected changes in 'obb_server.py'. Reloading...
+INFO:     Started server process [2239362]
+INFO:     Waiting for application startup.
+INFO:     Application startup complete.
+INFO:     Will watch for changes in these directories: ['/home/dage/guqing/depoly/yolov11_depoly/depoly/obb_detect_Cultural relics disease detection']
+ERROR:    [Errno 98] Address already in use
+INFO:     Will watch for changes in these directories: ['/home/dage/guqing/depoly/yolov11_depoly/depoly/obb_detect_Cultural relics disease detection']
+ERROR:    [Errno 98] Address already in use
+INFO:     Will watch for changes in these directories: ['/home/dage/guqing/depoly/yolov11_depoly/depoly/obb_detect_Cultural relics disease detection']
+INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
+INFO:     Started reloader process [2247437] using StatReload
+INFO:     Started server process [2247456]
+INFO:     Waiting for application startup.
+INFO:     Application startup complete.
+应用启动...开始加载模型...
+模型加载完成!
+
+0: 1280x2560 1 破损与剥落, 2 微生物侵害s, 7 渗水s, 2269.4ms
+Speed: 13.7ms preprocess, 2269.4ms inference, 4.8ms postprocess per image at shape (1, 3, 1280, 2560)
+INFO:     192.168.9.52:60868 - "POST /obb HTTP/1.1" 200 OK
+
+0: 1280x2560 1 破损与剥落, 2 微生物侵害s, 7 渗水s, 2224.9ms
+Speed: 11.0ms preprocess, 2224.9ms inference, 0.8ms postprocess per image at shape (1, 3, 1280, 2560)
+INFO:     192.168.9.52:52746 - "POST /obb HTTP/1.1" 200 OK
+
+0: 1280x2560 1 破损与剥落, 2 微生物侵害s, 7 渗水s, 2226.7ms
+Speed: 9.8ms preprocess, 2226.7ms inference, 0.7ms postprocess per image at shape (1, 3, 1280, 2560)
+INFO:     172.23.0.11:54924 - "POST /obb HTTP/1.1" 200 OK
+
+0: 1280x2560 1 破损与剥落, 2 微生物侵害s, 7 渗水s, 2359.0ms
+Speed: 12.2ms preprocess, 2359.0ms inference, 0.7ms postprocess per image at shape (1, 3, 1280, 2560)
+INFO:     192.168.9.52:37124 - "POST /obb HTTP/1.1" 200 OK
+
+0: 1280x2560 1 破损与剥落, 2 微生物侵害s, 7 渗水s, 2271.5ms
+Speed: 10.5ms preprocess, 2271.5ms inference, 0.7ms postprocess per image at shape (1, 3, 1280, 2560)
+INFO:     192.168.9.52:34686 - "POST /obb HTTP/1.1" 200 OK

BIN
depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/nolabel.jpg


+ 105 - 0
depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/obb_client.py

@@ -0,0 +1,105 @@
+import requests
+import json
+import os
+import base64
+from PIL import Image, ImageDraw, ImageFont
+import numpy as np
+import cv2
+
+# FastAPI 服务器的地址
+API_HOST = os.getenv("API_HOST", "192.168.9.113")
+API_PORT = os.getenv("API_PORT", "8000")
+BASE_URL = f"http://{API_HOST}:{API_PORT}"
+
+# 测试的图片路径,保存路径,保存json
+IMAGE_PATH = "./SG-0uQb047fxOJ_0.jpg"
+# IMAGE_PATH = "./nolabel.jpg"
+json_filename = "./obb_results.json"
+result_image_filename = "./result_image.jpg"
+
+
+def test_endpoint_with_base64():
+    """使用 Base64 编码测试指定的 API 端点"""
+    url = f"{BASE_URL}/obb"
+    print(f"--- 正在使用 Base64 测试端点: {url} ---")
+    try:
+        # 1. 读取并编码图片
+        with open(IMAGE_PATH, "rb") as f:
+            image_data = f.read()
+            base64_encoded_image = base64.b64encode(image_data).decode('utf-8')
+
+        # 2. 构建 JSON payload
+        payload = {
+            "image_data": base64_encoded_image,
+            "filename": os.path.basename(IMAGE_PATH)
+        }
+
+        # 3. 发送 POST 请求
+        response = requests.post(url, json=payload)
+
+        if response.status_code == 200:
+            print("请求成功!")
+            pretty_json = json.dumps(response.json(), indent=4, ensure_ascii=False)
+            print(pretty_json)  ###检测出的所有信息,按需生成json文件
+
+            # 4. 保存 JSON 文件
+            with open(json_filename, "w", encoding='utf-8') as f:
+                json.dump(response.json(), f, indent=4, ensure_ascii=False)
+            print(f"JSON 结果已保存到 {json_filename}")
+
+            # 5. 在图像上绘制结果并保存
+            try:
+                obbs = response.json().get("shapes", [])
+                FONT_PATH = "../../font/华文行楷.ttf"
+                FONT_SIZE = 30
+                font = ImageFont.truetype(FONT_PATH, FONT_SIZE)
+                image = Image.open(IMAGE_PATH).convert("RGB")
+                draw = ImageDraw.Draw(image)
+
+                for obb in obbs:
+                    class_name = obb.get("name")
+                    confidence = obb.get("score")
+                    if class_name == None:
+                        continue
+                    else:
+                        text = f"{class_name}: {confidence:.2f}"
+                        # bbox = [np.array(obb['bbox']).reshape((-1, 2)).astype(np.int32)]
+                        bbox = obb['bbox']
+                        x_coords = bbox[0::2]  # 从索引 0 开始,每隔 2 个取一个 (x1, x2, x3, x4)
+                        y_coords = bbox[1::2]  # 从索引 1 开始,每隔 2 个取一个 (y1, y2, y3, y4)
+                        bbox = list(zip(x_coords, y_coords))
+                        draw.polygon(
+                            bbox,
+                            outline="red",
+                            width=2
+                        )
+                        puttext_x, puttext_y = obb['bbox'][0], obb['bbox'][1]
+                        draw.text(
+                            (puttext_x, puttext_y - FONT_SIZE),  # 向上移动一点,避免与框重叠
+                            text,
+                            fill="red",
+                            font=font  # <-- 关键:指定字体对象
+                        )
+                image.save(result_image_filename)
+                print(f"绘制了结果的图像已保存到 {result_image_filename}")
+
+            except Exception as e:
+                print(f"绘制或保存图像时出错: {e}")
+
+        else:
+            print(f"请求失败,状态码: {response.status_code}")
+            print("错误信息:", response.text)
+
+        print("-" * (40 + len("obb")))
+        print("\n")
+
+    except FileNotFoundError:
+        print(f"错误:测试图片,json '{IMAGE_PATH}' 未找到。")
+    except requests.exceptions.ConnectionError:
+        print(f"错误:无法连接到服务器 '{BASE_URL}'。请确保 FastAPI 服务正在运行。")
+    except Exception as e:
+        print(f"处理请求时出错: {e}")
+
+
+if __name__ == "__main__":
+    test_endpoint_with_base64()

+ 111 - 0
depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/obb_client_cpu.py

@@ -0,0 +1,111 @@
+import requests
+import json
+import os
+import base64
+import argparse
+from PIL import Image, ImageDraw, ImageFont
+
+# --- 环境配置 ---
+API_HOST = os.getenv("API_HOST", "192.168.9.113")
+API_PORT = os.getenv("API_PORT", "8000")
+BASE_URL = f"http://{API_HOST}:{API_PORT}"
+
+
+def run_obb_client(image_path):
+    """
+    处理 OBB (旋转框) 检测请求的主函数
+    """
+    url = f"{BASE_URL}/obb"
+
+    # 自动生成输出文件名 (例如: 输入 test.jpg -> 输出 res_test.json)
+    base_name = os.path.splitext(os.path.basename(image_path))[0]
+    json_out = f"res_{base_name}.json"
+    image_out = f"res_{base_name}.jpg"
+
+    print(f"[*] 正在处理图片: {image_path}")
+
+    try:
+        # 1. 图像编码
+        with open(image_path, "rb") as f:
+            base64_data = base64.b64encode(f.read()).decode('utf-8')
+
+        # 2. 构造请求
+        payload = {
+            "image_data": base64_data,
+            "filename": os.path.basename(image_path)
+        }
+
+        # 3. 发送请求
+        response = requests.post(url, json=payload, timeout=30)
+
+        if response.status_code == 200:
+            print("[+] 请求成功!")
+            data = response.json()
+
+            # 4. 保存 JSON 结果
+            with open(json_out, "w", encoding='utf-8') as f:
+                json.dump(data, f, indent=4, ensure_ascii=False)
+            print(f"[+] 结果已保存至: {json_out}")
+
+            # 5. 绘制结果
+            render_obb_results(image_path, data, image_out)
+        else:
+            print(f"[!] 请求失败 (状态码 {response.status_code}): {response.text}")
+
+    except FileNotFoundError:
+        print(f"[!] 错误: 找不到文件 '{image_path}'")
+    except Exception as e:
+        print(f"[!] 运行过程中出错: {e}")
+
+
+def render_obb_results(src_path, data, save_path):
+    """渲染旋转框并保存图片"""
+    try:
+        image = Image.open(src_path).convert("RGB")
+        draw = ImageDraw.Draw(image)
+
+        # 字体处理 (如果路径不存在则回退到默认字体)
+        FONT_PATH = "../../font/华文行楷.ttf"
+        FONT_SIZE = 30
+        try:
+            font = ImageFont.truetype(FONT_PATH, FONT_SIZE)
+        except:
+            font = ImageFont.load_default()
+
+        shapes = data.get("shapes", [])
+        for obj in shapes:
+            label = obj.get("name", "unknown")
+            score = obj.get("score", 0.0)
+            bbox_raw = obj.get("bbox", [])
+
+            if not bbox_raw:
+                continue
+
+            # 转换坐标格式为 [(x1, y1), (x2, y2), ...]
+            pts = list(zip(bbox_raw[0::2], bbox_raw[1::2]))
+
+            # 绘制旋转框 (Polygon)
+            draw.polygon(pts, outline="red", width=3)
+
+            # 绘制标签文本
+            text = f"{label}: {score:.2f}"
+            draw.text((bbox_raw[0], bbox_raw[1] - FONT_SIZE), text, fill="red", font=font)
+
+        image.save(save_path)
+        print(f"[+] 渲染图已保存至: {save_path}")
+
+    except Exception as e:
+        print(f"[!] 绘图失败: {e}")
+
+
+if __name__ == "__main__":
+    # --- 命令行参数配置 ---
+    parser = argparse.ArgumentParser(description="AI 旋转框 (OBB) 检测客户端")
+
+    # 传入图片参数 -i
+    parser.add_argument("-i", "--image", type=str, required=True, help="需要处理的图片路径")
+
+    args = parser.parse_args()
+
+    # 执行
+    run_obb_client(args.image)

BIN
depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/obb_detect_Cultural relics disease detection-2560.pt


+ 218 - 0
depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/obb_results.json

@@ -0,0 +1,218 @@
+{
+    "shapes": [
+        {
+            "bbox": [
+                830,
+                1596,
+                1056,
+                1578,
+                1043,
+                1408,
+                817,
+                1426
+            ],
+            "category": "Microbial_Infestation",
+            "color": [
+                255,
+                0,
+                255
+            ],
+            "label": "5 0.202637 0.779297 0.2578120.7705080.2546390.6875 0.199463 0.696289",
+            "name": "微生物侵害",
+            "score": 0.8207114934921265
+        },
+        {
+            "bbox": [
+                3442,
+                1138,
+                3696,
+                1135,
+                3696,
+                1087,
+                3442,
+                1089
+            ],
+            "category": "Damage_Spalling",
+            "color": [
+                0,
+                255,
+                0
+            ],
+            "label": "1 0.840332 0.555664 0.9023440.5541990.9023440.530762 0.840332 0.531738",
+            "name": "破损与剥落",
+            "score": 0.7491011619567871
+        },
+        {
+            "bbox": [
+                2251,
+                1032,
+                2852,
+                1030,
+                2851,
+                775,
+                2250,
+                777
+            ],
+            "category": "Construction_damage",
+            "color": [
+                0,
+                128,
+                0
+            ],
+            "label": "8 0.549561 0.503906 0.6962890.502930.6960450.378418 0.549316 0.379395",
+            "name": "渗水",
+            "score": 0.7380356788635254
+        },
+        {
+            "bbox": [
+                1396,
+                1645,
+                1409,
+                1598,
+                1181,
+                1531,
+                1167,
+                1578
+            ],
+            "category": "Microbial_Infestation",
+            "color": [
+                255,
+                0,
+                255
+            ],
+            "label": "5 0.34082 0.803223 0.3439940.7802730.288330.747559 0.284912 0.770508",
+            "name": "微生物侵害",
+            "score": 0.735342800617218
+        },
+        {
+            "bbox": [
+                3259,
+                1191,
+                3309,
+                1190,
+                3306,
+                942,
+                3256,
+                942
+            ],
+            "category": "Construction_damage",
+            "color": [
+                0,
+                128,
+                0
+            ],
+            "label": "8 0.795654 0.581543 0.8078610.5810550.8071290.459961 0.794922 0.459961",
+            "name": "渗水",
+            "score": 0.7126780152320862
+        },
+        {
+            "bbox": [
+                2727,
+                1138,
+                3296,
+                1134,
+                3293,
+                770,
+                2724,
+                774
+            ],
+            "category": "Construction_damage",
+            "color": [
+                0,
+                128,
+                0
+            ],
+            "label": "8 0.665771 0.555664 0.8046880.5537110.8039550.375977 0.665039 0.37793",
+            "name": "渗水",
+            "score": 0.695840060710907
+        },
+        {
+            "bbox": [
+                3365,
+                1134,
+                3757,
+                1129,
+                3755,
+                896,
+                3362,
+                900
+            ],
+            "category": "Construction_damage",
+            "color": [
+                0,
+                128,
+                0
+            ],
+            "label": "8 0.821533 0.553711 0.9172360.551270.9167480.4375 0.820801 0.439453",
+            "name": "渗水",
+            "score": 0.5947369933128357
+        },
+        {
+            "bbox": [
+                3241,
+                1118,
+                3242,
+                688,
+                2284,
+                685,
+                2283,
+                1115
+            ],
+            "category": "Construction_damage",
+            "color": [
+                0,
+                128,
+                0
+            ],
+            "label": "8 0.79126 0.545898 0.7915040.3359380.5576170.334473 0.557373 0.544434",
+            "name": "渗水",
+            "score": 0.3963906764984131
+        },
+        {
+            "bbox": [
+                3375,
+                1148,
+                3749,
+                1144,
+                3749,
+                1081,
+                3375,
+                1085
+            ],
+            "category": "Construction_damage",
+            "color": [
+                0,
+                128,
+                0
+            ],
+            "label": "8 0.823975 0.560547 0.9152830.5585940.9152830.527832 0.823975 0.529785",
+            "name": "渗水",
+            "score": 0.38440266251564026
+        },
+        {
+            "bbox": [
+                3081,
+                1157,
+                3291,
+                1150,
+                3289,
+                1086,
+                3079,
+                1093
+            ],
+            "category": "Construction_damage",
+            "color": [
+                0,
+                128,
+                0
+            ],
+            "label": "8 0.752197 0.564941 0.8034670.5615230.8029790.530273 0.751709 0.533691",
+            "name": "渗水",
+            "score": 0.31446343660354614
+        }
+    ],
+    "imageHeight": 2048,
+    "imagePath": "SG-0uQb047fxOJ_0.jpg",
+    "imageWidth": 4096,
+    "version": "4dage_cul_rel_dis_det_0.0.1"
+}

+ 158 - 0
depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/obb_server.py

@@ -0,0 +1,158 @@
+import io
+from PIL import Image
+from fastapi import FastAPI, File, UploadFile, HTTPException
+from fastapi.responses import JSONResponse
+from ultralytics import YOLO
+from contextlib import asynccontextmanager
+import base64
+import json
+import os
+import uvicorn
+
+COLOR_LIST = {
+    "Crack": (255, 0, 0),  # 红色
+    "Damage_Spalling": (0, 255, 0),  # 绿色
+    "Chalking": (0, 0, 255),  # 蓝色
+    "Surface_Dissolution": (255, 255, 0),  # 黄色
+    "Efflorescence": (0, 255, 255),  # 青色
+    "Microbial_Infestation": (255, 0, 255),  # 品红色
+    "Plant_Infestation": (192, 192, 192),  # 银色
+    "Animal_Infestation": (128, 0, 0),  # 褐红色
+    "Water_Seepage": (128, 128, 0),  # 橄榄色
+    "Construction_damage": (0, 128, 0),  # 深绿色
+    "Engraving": (128, 0, 128),  # 紫色
+    "Graffiti": (0, 128, 128),  # 蓝绿色
+    "Overuse": (0, 0, 128),  # 深蓝色
+    # (255, 165, 0),  # 橙色
+    # (255, 192, 203),  # 粉色
+    # (100, 149, 237),  # 矢车菊蓝
+    # (255, 215, 0),  # 金色
+    # (218, 165, 32),  # 金黄色
+    # (64, 224, 208),  # 绿松石
+    # (138, 43, 226),  # 蓝紫色
+}
+english_lables = ["Crack", "Damage_Spalling", "Chalking", "Surface_Dissolution", "Efflorescence",
+                  "Microbial_Infestation", "Plant_Infestation", "Animal_Infestation", "Water_Seepage",
+                  "Construction_damage",
+                  "Engraving", "Graffiti", "Overuse"]
+
+label_dic = {
+    "裂隙": english_lables[0],
+    "破损与剥落": english_lables[1],
+    "粉化": english_lables[2],
+    "表面溶蚀": english_lables[3],
+    "泛盐": english_lables[4],
+    "微生物侵害": english_lables[5],
+    "植物侵害": english_lables[7],
+    "动物侵害": english_lables[7],
+    "渗水": english_lables[9],
+    "施工破坏": english_lables[9],
+    "刻画": english_lables[10],
+    "涂鸦": english_lables[11],
+    "过度使用": english_lables[12],
+}
+
+
+def parse_obb_results(results, filename):
+    """解析旋转框检测结果"""
+    detect_results = []
+    imageHeight, imageWidth = results[0].orig_shape
+    imagePath = os.path.basename(filename)
+    img_inf = (imagePath, imageWidth, imageHeight)
+
+    obbs = []
+    for result in results:
+        boxes = result.obb.cpu().numpy()
+        if boxes.shape[0] == 0:
+            obbs.append({
+                "bbox": None,
+                "seg_points": None,
+                "category": None,
+                "color": None,
+                "label": None,
+                "name": None,
+                "score": None
+            })
+        else:
+            for i, box in enumerate(boxes):
+                points_list = box.xyxyxyxy[0].tolist()
+                points_list = [(int(point[0]), int(point[1])) for point in points_list]
+                all_x = [point[0] for point in points_list]
+                all_y = [point[1] for point in points_list]
+                x1, y1, x2, y2 = min(all_x), min(all_y), max(all_x), max(all_y)
+                yolov_x = [round(x / imageWidth, 6) for x in all_x]
+                yolov_y = [round(y / imageHeight, 6) for y in all_y]
+
+                obbs.append({
+                    # "bbox": points_list,
+                    "bbox": [all_x[0], all_y[0], all_x[1], all_y[1], all_x[2], all_y[2], all_x[3], all_y[3]],
+                    # "min_rec": [x1, y1, x2, y2],
+                    "category": label_dic[result.names[int(box.cls[0])]],
+                    "color": COLOR_LIST[label_dic[result.names[int(box.cls[0])]]],
+                    "label": f"{int(box.cls[0])} {yolov_x[0]} {yolov_y[0]} {yolov_x[1]}{yolov_y[1]}{yolov_x[2]}{yolov_y[2]} {yolov_x[3]} {yolov_y[3]}",
+                    "name": result.names[int(box.cls[0])],
+                    "score": float(box.conf[0])
+                })
+    return obbs, img_inf
+
+
+models = {}
+
+
+@asynccontextmanager
+async def lifespan(app: FastAPI):
+    # 在应用启动时执行
+    print("应用启动...开始加载模型...")
+
+    models["obb"] = YOLO('obb_detect_Cultural relics disease detection-2560.pt')
+
+    print("模型加载完成!")
+    yield
+    # 在应用关闭时执行 (如果需要)
+    print("应用关闭...")
+    models.clear()
+
+
+app = FastAPI(lifespan=lifespan)
+
+
+@app.get("/")
+def read_root():
+    return {"message": "欢迎使用 YOLO 系列模型部署 API"}
+
+
+@app.post("/obb")  # 假设您将此端点修改为接收 JSON 数据
+async def predict_obb(data: dict):
+    """旋转框检测任务,接收 Base64 编码的图片"""
+    try:
+        # 从 JSON 中获取 Base64 字符串
+        base64_string = data.get("image_data")
+        if not base64_string:
+            raise HTTPException(status_code=400, detail="未找到 'image_data' 字段")
+
+        # 解码 Base64 字符串
+        image_bytes = base64.b64decode(base64_string)
+
+        # 将字节流转换为 PIL.Image 对象
+        image = Image.open(io.BytesIO(image_bytes)).convert("RGB")
+
+        # 使用加载好的模型进行推理
+        results = models["obb"](image, imgsz=2560,device='cpu')
+        obbs, imginf = parse_obb_results(results, data.get("filename"))
+
+        content_data = JSONResponse(content={"shapes": obbs}).body.decode("utf-8")  # 获取原始JSON字符串
+        data_dict = json.loads(content_data)  # 解析为字典
+        # ✅ 添加新数据到shapes列表
+        data_dict.update({
+            "imageHeight": imginf[2],
+            "imagePath": imginf[0],
+            "imageWidth": imginf[1],
+            "version": "4dage_cul_rel_dis_det_0.0.1"
+        })
+
+        return JSONResponse(content=data_dict)
+    except Exception as e:
+        raise HTTPException(status_code=500, detail=f"处理图片时出错: {str(e)}")
+
+if __name__ == "__main__":
+    uvicorn.run("obb_server:app", host="0.0.0.0", port=8000, reload=True)

BIN
depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/res_SG-0uQb047fxOJ_0.jpg


+ 218 - 0
depoly_cultural relics and furniture/obb_detect_Cultural relics disease detection/res_SG-0uQb047fxOJ_0.json

@@ -0,0 +1,218 @@
+{
+    "shapes": [
+        {
+            "bbox": [
+                830,
+                1596,
+                1056,
+                1578,
+                1043,
+                1408,
+                817,
+                1426
+            ],
+            "category": "Microbial_Infestation",
+            "color": [
+                255,
+                0,
+                255
+            ],
+            "label": "5 0.202637 0.779297 0.2578120.7705080.2546390.6875 0.199463 0.696289",
+            "name": "微生物侵害",
+            "score": 0.8207162618637085
+        },
+        {
+            "bbox": [
+                3442,
+                1138,
+                3696,
+                1135,
+                3696,
+                1087,
+                3442,
+                1089
+            ],
+            "category": "Damage_Spalling",
+            "color": [
+                0,
+                255,
+                0
+            ],
+            "label": "1 0.840332 0.555664 0.9023440.5541990.9023440.530762 0.840332 0.531738",
+            "name": "破损与剥落",
+            "score": 0.7491047978401184
+        },
+        {
+            "bbox": [
+                2251,
+                1032,
+                2852,
+                1030,
+                2851,
+                775,
+                2250,
+                777
+            ],
+            "category": "Construction_damage",
+            "color": [
+                0,
+                128,
+                0
+            ],
+            "label": "8 0.549561 0.503906 0.6962890.502930.6960450.378418 0.549316 0.379395",
+            "name": "渗水",
+            "score": 0.7379715442657471
+        },
+        {
+            "bbox": [
+                1396,
+                1645,
+                1409,
+                1598,
+                1181,
+                1531,
+                1167,
+                1578
+            ],
+            "category": "Microbial_Infestation",
+            "color": [
+                255,
+                0,
+                255
+            ],
+            "label": "5 0.34082 0.803223 0.3439940.7802730.288330.747559 0.284912 0.770508",
+            "name": "微生物侵害",
+            "score": 0.7354218363761902
+        },
+        {
+            "bbox": [
+                3259,
+                1191,
+                3309,
+                1190,
+                3306,
+                942,
+                3256,
+                942
+            ],
+            "category": "Construction_damage",
+            "color": [
+                0,
+                128,
+                0
+            ],
+            "label": "8 0.795654 0.581543 0.8078610.5810550.8071290.459961 0.794922 0.459961",
+            "name": "渗水",
+            "score": 0.7127204537391663
+        },
+        {
+            "bbox": [
+                2727,
+                1138,
+                3296,
+                1134,
+                3293,
+                770,
+                2724,
+                774
+            ],
+            "category": "Construction_damage",
+            "color": [
+                0,
+                128,
+                0
+            ],
+            "label": "8 0.665771 0.555664 0.8046880.5537110.8039550.375977 0.665039 0.37793",
+            "name": "渗水",
+            "score": 0.6956157088279724
+        },
+        {
+            "bbox": [
+                3365,
+                1134,
+                3757,
+                1129,
+                3755,
+                896,
+                3362,
+                900
+            ],
+            "category": "Construction_damage",
+            "color": [
+                0,
+                128,
+                0
+            ],
+            "label": "8 0.821533 0.553711 0.9172360.551270.9167480.4375 0.820801 0.439453",
+            "name": "渗水",
+            "score": 0.5949665904045105
+        },
+        {
+            "bbox": [
+                3241,
+                1118,
+                3242,
+                688,
+                2284,
+                685,
+                2283,
+                1115
+            ],
+            "category": "Construction_damage",
+            "color": [
+                0,
+                128,
+                0
+            ],
+            "label": "8 0.79126 0.545898 0.7915040.3359380.5576170.334473 0.557373 0.544434",
+            "name": "渗水",
+            "score": 0.39645466208457947
+        },
+        {
+            "bbox": [
+                3375,
+                1148,
+                3749,
+                1144,
+                3749,
+                1081,
+                3375,
+                1085
+            ],
+            "category": "Construction_damage",
+            "color": [
+                0,
+                128,
+                0
+            ],
+            "label": "8 0.823975 0.560547 0.9152830.5585940.9152830.527832 0.823975 0.529785",
+            "name": "渗水",
+            "score": 0.38458052277565
+        },
+        {
+            "bbox": [
+                3081,
+                1157,
+                3291,
+                1150,
+                3289,
+                1086,
+                3079,
+                1093
+            ],
+            "category": "Construction_damage",
+            "color": [
+                0,
+                128,
+                0
+            ],
+            "label": "8 0.752197 0.564941 0.8034670.5615230.8029790.530273 0.751709 0.533691",
+            "name": "渗水",
+            "score": 0.31426259875297546
+        }
+    ],
+    "imageHeight": 2048,
+    "imagePath": "SG-0uQb047fxOJ_0.jpg",
+    "imageWidth": 4096,
+    "version": "4dage_cul_rel_dis_det_0.0.1"
+}

BIN
depoly_cultural relics and furniture/seg_detect_Panoramic_Home/KJ-vYL6GFH2fYw_30.jpg


BIN
depoly_cultural relics and furniture/seg_detect_Panoramic_Home/__pycache__/obb_client.cpython-38-pytest-8.3.5.pyc


BIN
depoly_cultural relics and furniture/seg_detect_Panoramic_Home/__pycache__/seg_client.cpython-38-pytest-8.3.5.pyc


BIN
depoly_cultural relics and furniture/seg_detect_Panoramic_Home/__pycache__/seg_server.cpython-312.pyc


BIN
depoly_cultural relics and furniture/seg_detect_Panoramic_Home/__pycache__/seg_server.cpython-38.pyc


+ 12 - 0
depoly_cultural relics and furniture/seg_detect_Panoramic_Home/load_result_json.py

@@ -0,0 +1,12 @@
+import json
+import cv2
+import numpy as np
+# 读取JSON文件
+with open("seg_results.json", "r", encoding="utf-8") as f:
+    obb_inf = json.load(f)  # 解析为Python字典/列表
+    img = cv2.imread(obb_inf['imagePath'])
+    obb_lists = obb_inf['shapes']
+    for obb in (obb_lists):
+        bbox = [np.array(obb['bbox']).reshape((-1, 2)).astype(np.int32)]
+        cv2.polylines(img, bbox, True, (0, 0, 255), thickness=4, lineType=cv2.LINE_8, shift=0)
+cv2.imwrite('output.png', img)

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 4234 - 0
depoly_cultural relics and furniture/seg_detect_Panoramic_Home/nohup.out


BIN
depoly_cultural relics and furniture/seg_detect_Panoramic_Home/nolabel.jpg


BIN
depoly_cultural relics and furniture/seg_detect_Panoramic_Home/res_KJ-vYL6GFH2fYw_30.jpg


+ 315 - 0
depoly_cultural relics and furniture/seg_detect_Panoramic_Home/res_KJ-vYL6GFH2fYw_30.json

@@ -0,0 +1,315 @@
+{
+    "shapes": [
+        {
+            "bbox": [
+                742,
+                409,
+                2126,
+                409,
+                2126,
+                1052,
+                742,
+                1052
+            ],
+            "seg_points": [
+                1177,
+                396,
+                1177,
+                416,
+                1171,
+                422,
+                1164,
+                422,
+                1158,
+                428,
+                1139,
+                428,
+                1132,
+                435,
+                1107,
+                435,
+                1100,
+                441,
+                1075,
+                441,
+                1068,
+                448,
+                1062,
+                448,
+                1056,
+                454,
+                1049,
+                454,
+                1043,
+                460,
+                1017,
+                460,
+                1011,
+                467,
+                998,
+                467,
+                992,
+                473,
+                979,
+                473,
+                972,
+                480,
+                966,
+                480,
+                960,
+                486,
+                947,
+                486,
+                940,
+                492,
+                928,
+                492,
+                915,
+                505,
+                908,
+                505,
+                902,
+                512,
+                883,
+                512,
+                876,
+                518,
+                870,
+                518,
+                857,
+                531,
+                851,
+                531,
+                844,
+                537,
+                838,
+                537,
+                832,
+                544,
+                825,
+                544,
+                806,
+                563,
+                800,
+                563,
+                793,
+                569,
+                787,
+                569,
+                780,
+                576,
+                774,
+                576,
+                761,
+                588,
+                729,
+                588,
+                729,
+                627,
+                748,
+                627,
+                761,
+                640,
+                761,
+                652,
+                768,
+                659,
+                768,
+                684,
+                761,
+                691,
+                761,
+                889,
+                768,
+                896,
+                768,
+                1056,
+                1011,
+                1056,
+                1011,
+                1004,
+                1017,
+                998,
+                1024,
+                998,
+                1030,
+                992,
+                1126,
+                992,
+                1132,
+                985,
+                1139,
+                985,
+                1145,
+                992,
+                1529,
+                992,
+                1536,
+                998,
+                1619,
+                998,
+                1625,
+                992,
+                1657,
+                992,
+                1664,
+                998,
+                1715,
+                998,
+                1721,
+                1004,
+                1728,
+                1004,
+                1734,
+                1011,
+                1804,
+                1011,
+                1811,
+                1017,
+                1913,
+                1017,
+                1920,
+                1024,
+                1964,
+                1024,
+                1977,
+                1036,
+                1977,
+                1056,
+                2086,
+                1056,
+                2086,
+                736,
+                2092,
+                729,
+                2092,
+                716,
+                2105,
+                704,
+                2131,
+                704,
+                2131,
+                678,
+                2112,
+                678,
+                2105,
+                672,
+                2099,
+                672,
+                2067,
+                640,
+                2060,
+                640,
+                2016,
+                595,
+                2009,
+                595,
+                2003,
+                588,
+                1996,
+                588,
+                1977,
+                569,
+                1971,
+                569,
+                1958,
+                556,
+                1952,
+                556,
+                1939,
+                544,
+                1932,
+                544,
+                1926,
+                537,
+                1913,
+                537,
+                1907,
+                531,
+                1900,
+                531,
+                1888,
+                518,
+                1881,
+                518,
+                1875,
+                512,
+                1862,
+                512,
+                1856,
+                505,
+                1849,
+                505,
+                1843,
+                499,
+                1836,
+                499,
+                1830,
+                492,
+                1824,
+                492,
+                1817,
+                486,
+                1804,
+                486,
+                1798,
+                480,
+                1785,
+                480,
+                1779,
+                473,
+                1772,
+                473,
+                1766,
+                467,
+                1753,
+                467,
+                1747,
+                460,
+                1721,
+                460,
+                1715,
+                454,
+                1702,
+                454,
+                1696,
+                448,
+                1689,
+                448,
+                1683,
+                441,
+                1664,
+                441,
+                1657,
+                435,
+                1625,
+                435,
+                1619,
+                428,
+                1593,
+                428,
+                1587,
+                422,
+                1580,
+                422,
+                1574,
+                416,
+                1574,
+                396
+            ],
+            "category": "Kitchen_Cabinet",
+            "color": [
+                190,
+                255,
+                220
+            ],
+            "label": "25 0.181152 0.199707 0.5190430.1997070.1811520.513672 0.519043 0.513672",
+            "name": "橱柜",
+            "score": 0.958259105682373
+        }
+    ],
+    "imageHeight": 2048,
+    "imagePath": "KJ-vYL6GFH2fYw_30.jpg",
+    "imageWidth": 4096,
+    "version": "4dage_furniture_det_0.0.1"
+}

+ 120 - 0
depoly_cultural relics and furniture/seg_detect_Panoramic_Home/seg_client.py

@@ -0,0 +1,120 @@
+import requests
+import json
+import os
+import base64
+from PIL import Image, ImageDraw, ImageFont
+import numpy as np
+import cv2
+
+# FastAPI 服务器的地址
+API_HOST = os.getenv("API_HOST", "192.168.9.113")
+API_PORT = os.getenv("API_PORT", "7000")
+BASE_URL = f"http://{API_HOST}:{API_PORT}"
+
+# 测试的图片路径,保存路径,保存json
+IMAGE_PATH = "./KJ-vYL6GFH2fYw_30.jpg"
+# IMAGE_PATH = "./nolabel.jpg"
+json_filename = "seg_results.json"
+result_image_filename = "./result_image.jpg"
+
+def test_endpoint_with_base64():
+    """使用 Base64 编码测试指定的 API 端点"""
+    url = f"{BASE_URL}/seg"
+    print(f"--- 正在使用 Base64 测试端点: {url} ---")
+    try:
+        # 1. 读取并编码图片
+        with open(IMAGE_PATH, "rb") as f:
+            image_data = f.read()
+            base64_encoded_image = base64.b64encode(image_data).decode('utf-8')
+
+        # 2. 构建 JSON payload
+        payload = {
+            "image_data": base64_encoded_image,
+            "filename": os.path.basename(IMAGE_PATH)
+        }
+
+        # 3. 发送 POST 请求
+        response = requests.post(url, json=payload)
+
+        if response.status_code == 200:
+            print("请求成功!")
+            pretty_json = json.dumps(response.json(), indent=4, ensure_ascii=False)
+            print(pretty_json)  ###检测出的所有信息,按需生成json文件
+
+            # 4. 保存 JSON 文件
+            with open(json_filename, "w", encoding='utf-8') as f:
+                json.dump(response.json(), f, indent=4, ensure_ascii=False)
+            print(f"JSON 结果已保存到 {json_filename}")
+
+            # 5. 在图像上绘制结果并保存
+            try:
+                segs = response.json().get("shapes", [])
+                FONT_PATH = "../../font/华文行楷.ttf"
+                FONT_SIZE = 30
+                font = ImageFont.truetype(FONT_PATH, FONT_SIZE)
+                image = Image.open(IMAGE_PATH).convert("RGB")
+                draw = ImageDraw.Draw(image)
+
+                for seg in segs:
+                    class_name = seg.get("name")
+                    confidence = seg.get("score")
+                    if class_name == None:
+                        continue
+                    else:
+                        text = f"{class_name}: {confidence:.2f}"
+
+                        ########bbox
+                        bbox = seg['bbox']
+                        x_coords = bbox[0::2]  # 从索引 0 开始,每隔 2 个取一个 (x1, x2, x3, x4)
+                        y_coords = bbox[1::2]  # 从索引 1 开始,每隔 2 个取一个 (y1, y2, y3, y4)
+                        bbox = list(zip(x_coords, y_coords))
+                        ########bbox
+
+                        ########segs
+                        segpoints = seg['seg_points']
+                        x_segcoords = segpoints[0::2]  # 从索引 0 开始,每隔 2 个取一个 (x1, x2, x3, x4)
+                        y_segcoords = segpoints[1::2]  # 从索引 1 开始,每隔 2 个取一个 (y1, y2, y3, y4)
+                        segpoints_list = list(zip(x_segcoords, y_segcoords))
+                        ########segs
+
+                        draw.polygon(
+                            bbox,
+                            outline="red",
+                            width=4
+                        )
+
+                        draw.polygon(
+                            segpoints_list,
+                            outline="black",
+                            width=4
+                        )
+                        puttext_x, puttext_y = seg['bbox'][0], seg['bbox'][1]
+                        draw.text(
+                            (puttext_x, puttext_y - FONT_SIZE),  # 向上移动一点,避免与框重叠
+                            text,
+                            fill="red",
+                            font=font  # <-- 关键:指定字体对象
+                        )
+                image.save(result_image_filename)
+                print(f"绘制了结果的图像已保存到 {result_image_filename}")
+
+            except Exception as e:
+                print(f"绘制或保存图像时出错: {e}")
+
+        else:
+            print(f"请求失败,状态码: {response.status_code}")
+            print("错误信息:", response.text)
+
+        print("-" * (40 + len("seg")))
+        print("\n")
+
+    except FileNotFoundError:
+        print(f"错误:测试图片,json '{IMAGE_PATH}' 未找到。")
+    except requests.exceptions.ConnectionError:
+        print(f"错误:无法连接到服务器 '{BASE_URL}'。请确保 FastAPI 服务正在运行。")
+    except Exception as e:
+        print(f"处理请求时出错: {e}")
+
+
+if __name__ == "__main__":
+    test_endpoint_with_base64()

+ 103 - 0
depoly_cultural relics and furniture/seg_detect_Panoramic_Home/seg_client_cpu.py

@@ -0,0 +1,103 @@
+import requests
+import json
+import os
+import base64
+import argparse
+from PIL import Image, ImageDraw, ImageFont
+
+# --- 配置区 ---
+API_HOST = os.getenv("API_HOST", "192.168.9.113")
+API_PORT = os.getenv("API_PORT", "7000")
+BASE_URL = f"http://{API_HOST}:{API_PORT}"
+
+
+def process_image(image_path):
+    """发送图片到服务器并保存渲染结果"""
+    url = f"{BASE_URL}/seg"
+
+    # 根据输入文件名自动生成输出文件名
+    file_root = os.path.splitext(os.path.basename(image_path))[0]
+    json_output = f"res_{file_root}.json"
+    image_output = f"res_{file_root}.jpg"
+
+    print(f"[*] 正在处理: {image_path}")
+
+    try:
+        # 1. 读取图片并转为 Base64
+        with open(image_path, "rb") as f:
+            img_base64 = base64.b64encode(f.read()).decode('utf-8')
+
+        # 2. 准备 Payload
+        payload = {
+            "image_data": img_base64,
+            "filename": os.path.basename(image_path)
+        }
+
+        # 3. 提交请求
+        response = requests.post(url, json=payload, timeout=30)
+        response.raise_for_status()  # 如果状态码不是 200 会抛出异常
+
+        results = response.json()
+        print(f"[+] 请求成功,服务器返回了 {len(results.get('shapes', []))} 个目标")
+
+        # 4. 保存 JSON
+        with open(json_output, "w", encoding='utf-8') as f:
+            json.dump(results, f, indent=4, ensure_ascii=False)
+        print(f"[+] 数据已存至: {json_output}")
+
+        # 5. 渲染图片
+        render_results(image_path, results, image_output)
+
+    except Exception as e:
+        print(f"[!] 发生错误: {e}")
+
+
+def render_results(src_path, data, save_path):
+    """在图片上绘制 BBox 和分割点"""
+    try:
+        image = Image.open(src_path).convert("RGB")
+        draw = ImageDraw.Draw(image)
+
+        # 字体处理
+        try:
+            font = ImageFont.truetype("../../font/华文行楷.ttf", 30)
+        except:
+            font = ImageFont.load_default()
+
+        for shape in data.get("shapes", []):
+            label = shape.get("name", "unknown")
+            score = shape.get("score", 0.0)
+
+            # 绘制分割多边形 (Segmentation)
+            seg_pts = shape.get("seg_points", [])
+            if seg_pts:
+                pts = list(zip(seg_pts[0::2], seg_pts[1::2]))
+                draw.polygon(pts, outline="blue", width=2)
+
+            # 绘制检测框 (BBox)
+            bbox_pts = shape.get("bbox", [])
+            if bbox_pts:
+                box = list(zip(bbox_pts[0::2], bbox_pts[1::2]))
+                draw.polygon(box, outline="red", width=3)
+
+                # 写文字
+                draw.text((bbox_pts[0], bbox_pts[1] - 35), f"{label} {score:.2f}", fill="red", font=font)
+
+        image.save(save_path)
+        print(f"[+] 结果图已存至: {save_path}")
+
+    except Exception as e:
+        print(f"[!] 绘图失败: {e}")
+
+
+if __name__ == "__main__":
+    # --- 命令行参数解析 ---
+    parser = argparse.ArgumentParser(description="AI 图像分割客户端")
+
+    # 添加 -i / --image 参数
+    parser.add_argument("-i", "--image", type=str, required=True, help="需要处理的图片路径")
+
+    args = parser.parse_args()
+
+    # 运行主逻辑
+    process_image(args.image)

BIN
depoly_cultural relics and furniture/seg_detect_Panoramic_Home/seg_detect_Panoramic_Home.pt


+ 315 - 0
depoly_cultural relics and furniture/seg_detect_Panoramic_Home/seg_results.json

@@ -0,0 +1,315 @@
+{
+    "shapes": [
+        {
+            "bbox": [
+                742,
+                409,
+                2126,
+                409,
+                2126,
+                1052,
+                742,
+                1052
+            ],
+            "seg_points": [
+                1177,
+                396,
+                1177,
+                416,
+                1171,
+                422,
+                1164,
+                422,
+                1158,
+                428,
+                1139,
+                428,
+                1132,
+                435,
+                1107,
+                435,
+                1100,
+                441,
+                1075,
+                441,
+                1068,
+                448,
+                1062,
+                448,
+                1056,
+                454,
+                1049,
+                454,
+                1043,
+                460,
+                1017,
+                460,
+                1011,
+                467,
+                998,
+                467,
+                992,
+                473,
+                979,
+                473,
+                972,
+                480,
+                966,
+                480,
+                960,
+                486,
+                947,
+                486,
+                940,
+                492,
+                928,
+                492,
+                915,
+                505,
+                908,
+                505,
+                902,
+                512,
+                883,
+                512,
+                876,
+                518,
+                870,
+                518,
+                857,
+                531,
+                851,
+                531,
+                844,
+                537,
+                838,
+                537,
+                832,
+                544,
+                825,
+                544,
+                806,
+                563,
+                800,
+                563,
+                793,
+                569,
+                787,
+                569,
+                780,
+                576,
+                774,
+                576,
+                761,
+                588,
+                729,
+                588,
+                729,
+                627,
+                748,
+                627,
+                761,
+                640,
+                761,
+                652,
+                768,
+                659,
+                768,
+                684,
+                761,
+                691,
+                761,
+                889,
+                768,
+                896,
+                768,
+                1056,
+                1011,
+                1056,
+                1011,
+                1004,
+                1017,
+                998,
+                1024,
+                998,
+                1030,
+                992,
+                1126,
+                992,
+                1132,
+                985,
+                1139,
+                985,
+                1145,
+                992,
+                1529,
+                992,
+                1536,
+                998,
+                1619,
+                998,
+                1625,
+                992,
+                1657,
+                992,
+                1664,
+                998,
+                1715,
+                998,
+                1721,
+                1004,
+                1728,
+                1004,
+                1734,
+                1011,
+                1804,
+                1011,
+                1811,
+                1017,
+                1913,
+                1017,
+                1920,
+                1024,
+                1964,
+                1024,
+                1977,
+                1036,
+                1977,
+                1056,
+                2086,
+                1056,
+                2086,
+                736,
+                2092,
+                729,
+                2092,
+                716,
+                2105,
+                704,
+                2131,
+                704,
+                2131,
+                678,
+                2112,
+                678,
+                2105,
+                672,
+                2099,
+                672,
+                2067,
+                640,
+                2060,
+                640,
+                2016,
+                595,
+                2009,
+                595,
+                2003,
+                588,
+                1996,
+                588,
+                1977,
+                569,
+                1971,
+                569,
+                1958,
+                556,
+                1952,
+                556,
+                1939,
+                544,
+                1932,
+                544,
+                1926,
+                537,
+                1913,
+                537,
+                1907,
+                531,
+                1900,
+                531,
+                1888,
+                518,
+                1881,
+                518,
+                1875,
+                512,
+                1862,
+                512,
+                1856,
+                505,
+                1849,
+                505,
+                1843,
+                499,
+                1836,
+                499,
+                1830,
+                492,
+                1824,
+                492,
+                1817,
+                486,
+                1804,
+                486,
+                1798,
+                480,
+                1785,
+                480,
+                1779,
+                473,
+                1772,
+                473,
+                1766,
+                467,
+                1753,
+                467,
+                1747,
+                460,
+                1721,
+                460,
+                1715,
+                454,
+                1702,
+                454,
+                1696,
+                448,
+                1689,
+                448,
+                1683,
+                441,
+                1664,
+                441,
+                1657,
+                435,
+                1625,
+                435,
+                1619,
+                428,
+                1593,
+                428,
+                1587,
+                422,
+                1580,
+                422,
+                1574,
+                416,
+                1574,
+                396
+            ],
+            "category": "Kitchen_Cabinet",
+            "color": [
+                190,
+                255,
+                220
+            ],
+            "label": "25 0.181152 0.199707 0.5190430.1997070.1811520.513672 0.519043 0.513672",
+            "name": "橱柜",
+            "score": 0.9582321643829346
+        }
+    ],
+    "imageHeight": 2048,
+    "imagePath": "KJ-vYL6GFH2fYw_30.jpg",
+    "imageWidth": 4096,
+    "version": "4dage_cul_rel_dis_det_0.0.1"
+}

+ 205 - 0
depoly_cultural relics and furniture/seg_detect_Panoramic_Home/seg_server.py

@@ -0,0 +1,205 @@
+import io
+from PIL import Image
+from fastapi import FastAPI, File, UploadFile, HTTPException
+from fastapi.responses import JSONResponse
+from ultralytics import YOLO
+from contextlib import asynccontextmanager
+import base64
+import json
+import os
+import uvicorn
+import numpy as np
+
+COLOR_LIST = {
+    "Single_Door": (255, 0, 0), "Double_Door": (0, 255, 0), "Sliding_Door": (0, 0, 255),
+    "Doorway_Opening": (255, 255, 0), "Mother_Son_Door": (0, 255, 255), "Revolving_Door": (255, 0, 255),
+    "Rolling_Gate": (192, 192, 192), "Rolling_Shutter_Door": (128, 0, 0), "Door_Window_Combo": (128, 128, 0),
+    "Casement_Window": (0, 128, 0), "Sliding_Window": (128, 0, 128), "French_Window": (0, 128, 128),
+    "Bay_Window": (0, 0, 128), "Single_Bay_Window": (255, 165, 0), "Three_Seat_Sofa": (255, 192, 203),
+    "Single_Seat_Sofa": (100, 149, 237), "Corner_Sofa": (255, 215, 0), "Coffee_Table": (218, 165, 32),
+    "Side_Table": (255, 170, 170), "TV_Cabinet": (170, 255, 170), "Wardrobe": (170, 170, 255),
+    "Dressing_Table": (255, 255, 170), "Nightstand": (170, 255, 255), "Shoe_Cabinet": (255, 170, 255),
+    "Sideboard": (255, 220, 190), "Kitchen_Cabinet": (190, 255, 220), "Bathroom_Cabinet": (220, 190, 255),
+    "Bookshelf": (255, 190, 220), "Dining_Table": (190, 220, 255), "Desk": (220, 255, 190),
+    "Chair": (130, 220, 130), "Stool": (220, 130, 130), "Bench": (130, 130, 220),
+    "Double_Bed": (220, 220, 130), "Single_Bed": (130, 220, 220), "Gas_Stove": (220, 130, 220),
+    "Sink": (150, 50, 50), "Bathtub": (50, 150, 50), "Toilet": (50, 50, 150),
+    "Squat_Toilet": (150, 150, 50), "Vanity_Unit": (50, 150, 150), "Shower_Head": (150, 50, 150),
+    "Mop_Sink": (100, 0, 0), "Rug": (0, 100, 0), "Washing_Machine": (0, 0, 100),
+    "TV": (100, 100, 0), "Refrigerator": (0, 100, 100), "Wall_Mounted_AC": (100, 0, 100),
+    "Cabinet_AC": (75, 75, 75), "Water_Dispenser": (175, 175, 175), "Hair_Dryer": (25, 25, 25),
+    "Microwave": (225, 225, 225), "Grill": (10, 140, 10), "Robot_Vacuum": (140, 10, 10),
+    "Table_Lamp": (10, 10, 140), "Living_Room": (140, 140, 10), "Dining_Room": (10, 140, 140),
+    "Bedroom": (140, 10, 140), "Bathroom": (240, 100, 0), "Balcony": (0, 240, 100),
+    "Entrance": (100, 0, 240), "Storage_Room": (240, 0, 100), "Community_Name": (0, 100, 240),
+    "Community_Gate": (100, 240, 0), "Building_Number": (100, 100, 100), "Floor_Number": (200, 200, 200),
+    "House_Number": (255, 10, 10), "Room_Number": (10, 255, 10)
+}
+
+english_lables = [
+    "Single_Door", "Double_Door", "Sliding_Door", "Doorway_Opening", "Mother_Son_Door", "Rolling_Gate",
+    "Rolling_Shutter_Door", "Revolving_Door", "Door_Window_Combo", "Casement_Window", "Sliding_Window",
+    "French_Window", "Bay_Window", "Single_Bay_Window", "Three_Seat_Sofa", "Single_Seat_Sofa",
+    "Corner_Sofa", "Coffee_Table", "Side_Table", "TV_Cabinet", "Wardrobe", "Dressing_Table",
+    "Nightstand", "Shoe_Cabinet", "Sideboard", "Kitchen_Cabinet", "Bathroom_Cabinet", "Bookshelf",
+    "Dining_Table", "Desk", "Chair", "Stool", "Bench", "Double_Bed", "Single_Bed", "Gas_Stove",
+    "Sink", "Bathtub", "Toilet", "Squat_Toilet", "Vanity_Unit", "Shower_Head", "Mop_Sink", "Rug",
+    "Washing_Machine", "TV", "Refrigerator", "Wall_Mounted_AC", "Cabinet_AC", "Water_Dispenser",
+    "Hair_Dryer", "Microwave", "Grill", "Robot_Vacuum", "Table_Lamp", "Living_Room", "Dining_Room",
+    "Bedroom", "Bathroom", "Balcony", "Entrance", "Storage_Room", "Community_Name", "Community_Gate",
+    "Building_Number", "Floor_Number", "House_Number", "Room_Number"
+]
+
+label_dic = {
+    "单开门": "Single_Door", "双开门": "Double_Door", "移门": "Sliding_Door", "垭口": "Doorway_Opening",
+    "子母门": "Mother_Son_Door", "拉闸门": "Rolling_Gate", "卷闸门": "Rolling_Shutter_Door",
+    "旋转门": "Revolving_Door", "门联窗": "Door_Window_Combo", "平开窗": "Casement_Window",
+    "推拉窗": "Sliding_Window", "落地窗": "French_Window", "飘窗": "Bay_Window",
+    "单面飘窗": "Single_Bay_Window", "三人沙发": "Three_Seat_Sofa", "单人沙发": "Single_Seat_Sofa",
+    "转角沙发": "Corner_Sofa", "茶几": "Coffee_Table", "边几": "Side_Table",
+    "电视柜": "TV_Cabinet", "衣柜": "Wardrobe", "梳妆台": "Dressing_Table",
+    "床头柜": "Nightstand", "鞋柜": "Shoe_Cabinet", "边柜": "Sideboard",
+    "橱柜": "Kitchen_Cabinet", "浴室柜": "Bathroom_Cabinet", "书柜": "Bookshelf",
+    "餐桌": "Dining_Table", "书桌": "Desk", "椅子": "Chair", "凳子": "Stool",
+    "条凳": "Bench", "双人床": "Double_Bed", "单人床": "Single_Bed", "燃气灶": "Gas_Stove",
+    "水槽": "Sink", "浴缸": "Bathtub", "马桶": "Toilet", "蹲便器": "Squat_Toilet",
+    "洗漱台": "Vanity_Unit", "花洒": "Shower_Head", "拖把池": "Mop_Sink", "地毯": "Rug",
+    "洗衣机": "Washing_Machine", "电视": "TV", "冰箱": "Refrigerator",
+    "挂式空调": "Wall_Mounted_AC", "柜式空调": "Cabinet_AC", "饮水机": "Water_Dispenser",
+    "吹风机": "Hair_Dryer", "微波炉": "Microwave", "烧烤架": "Grill",
+    "扫地机器人": "Robot_Vacuum", "台灯": "Table_Lamp", "客厅": "Living_Room",
+    "餐厅": "Dining_Room", "卧室": "Bedroom", "卫生间": "Bathroom", "阳台": "Balcony",
+    "玄关": "Entrance", "储物间": "Storage_Room", "小区名": "Community_Name",
+    "小区大门": "Community_Gate", "楼号": "Building_Number", "楼层": "Floor_Number",
+    "门牌号": "House_Number", "房号": "Room_Number"
+}
+
+
+def parse_seg_results(results, filename):
+    """解析旋转框检测结果"""
+    detect_results = []
+    imageHeight, imageWidth = results[0].orig_shape
+    imagePath = os.path.basename(filename)
+    img_inf = (imagePath, imageWidth, imageHeight)
+
+    segs = []
+    for result in results:
+        xywh = result.boxes.xywh.cpu().numpy()
+        box = result.boxes.cpu().numpy()
+        if box.shape[0] == 0:
+            segs.append({
+                "bbox": None,
+                "seg_points": None,
+                "category": None,
+                "color": None,
+                "label": None,
+                "name": None,
+                "score": None
+            })
+        else:
+            x_c, y_c, w, h = int(xywh[0, 0]), int(xywh[0, 1]), int(xywh[0, 2]), int(xywh[0, 3])
+            x = int(x_c - w / 2)
+            y = int(y_c - h / 2)
+            x1, y1, x2, y2 = x, y, x + w, y + h  # 左上角顶点和右下角顶点
+
+            ##############
+            points_list = []
+            tlp = (x1, y1)
+            trp = (x2, y1)
+            blp = (x1, y2)
+            brp = (x2, y2)
+            points_list.append(tlp)
+            points_list.append(trp)
+            points_list.append(blp)
+            points_list.append(brp)
+            all_x = [point[0] for point in points_list]
+            all_y = [point[1] for point in points_list]
+            ##############
+
+            segments_xy = result.masks.xy[0]  # 归一化坐标,形状通常是 (N, 2) 的一维数组
+            imageHeight, imageWidth = result.orig_shape
+            seg_points = []
+            length = segments_xy.shape[0]
+
+            for i in range(length):
+                x, y = (int(segments_xy[i, :][0]), int(segments_xy[i, :][1]))
+                seg_points.append(x)
+                seg_points.append(y)
+
+            yolov_x = [round(x / imageWidth, 6) for x in all_x]
+            yolov_y = [round(y / imageHeight, 6) for y in all_y]
+
+            segs.append({
+                "bbox": [x1, y1, x2, y1, x2, y2, x1, y2],
+                "seg_points": seg_points,
+                "category": label_dic[result.names[int(box.cls[0])]],
+                "color": COLOR_LIST[label_dic[result.names[int(box.cls[0])]]],
+                "label": f"{int(box.cls[0])} {yolov_x[0]} {yolov_y[0]} {yolov_x[1]}{yolov_y[1]}{yolov_x[2]}{yolov_y[2]} {yolov_x[3]} {yolov_y[3]}",
+                "name": result.names[int(box.cls[0])],
+                "score": float(box.conf[0])
+            })
+    return segs, img_inf
+
+
+models = {}
+
+
+@asynccontextmanager
+async def lifespan(app: FastAPI):
+    # 在应用启动时执行
+    print("应用启动...开始加载模型...")
+
+    models["seg"] = YOLO('seg_detect_Panoramic_Home.pt')
+
+    print("模型加载完成!")
+    yield
+    # 在应用关闭时执行 (如果需要)
+    print("应用关闭...")
+    models.clear()
+
+
+app = FastAPI(lifespan=lifespan)
+
+
+@app.get("/")
+def read_root():
+    return {"message": "欢迎使用 YOLO 系列模型部署 API"}
+
+
+@app.post("/seg")  # 假设您将此端点修改为接收 JSON 数据
+async def predict_seg(data: dict):
+    """旋转框检测任务,接收 Base64 编码的图片"""
+    try:
+        # 从 JSON 中获取 Base64 字符串
+        base64_string = data.get("image_data")
+        if not base64_string:
+            raise HTTPException(status_code=400, detail="未找到 'image_data' 字段")
+
+        # 解码 Base64 字符串
+        image_bytes = base64.b64decode(base64_string)
+
+        # 将字节流转换为 PIL.Image 对象
+        image = Image.open(io.BytesIO(image_bytes)).convert("RGB")
+
+        # 使用加载好的模型进行推理
+        # results = models["seg"](image, imgsz=2560)
+        results = models["seg"](image, imgsz=640,device='cpu')
+        segs, imginf = parse_seg_results(results, data.get("filename"))
+
+        content_data = JSONResponse(content={"shapes": segs}).body.decode("utf-8")  # 获取原始JSON字符串
+        data_dict = json.loads(content_data)  # 解析为字典
+        # ✅ 添加新数据到shapes列表
+        data_dict.update({
+            "imageHeight": imginf[2],
+            "imagePath": imginf[0],
+            "imageWidth": imginf[1],
+            "version": "4dage_furniture_det_0.0.1"
+        })
+
+        return JSONResponse(content=data_dict)
+    except Exception as e:
+        raise HTTPException(status_code=500, detail=f"处理图片时出错: {str(e)}")
+
+
+if __name__ == "__main__":
+    uvicorn.run("seg_server:app", host="0.0.0.0", port=7000, reload=True)

+ 202 - 0
depoly_cultural relics and furniture/seg_detect_Panoramic_Home/server_copy.py

@@ -0,0 +1,202 @@
+import io
+from PIL import Image
+from fastapi import FastAPI, File, UploadFile, HTTPException
+from fastapi.responses import JSONResponse
+from ultralytics import YOLO
+from contextlib import asynccontextmanager
+import base64
+import json
+import os
+import uvicorn
+import numpy as np
+
+COLOR_LIST = {
+    "Single_Door": (255, 0, 0), "Double_Door": (0, 255, 0), "Sliding_Door": (0, 0, 255),
+    "Doorway_Opening": (255, 255, 0), "Mother_Son_Door": (0, 255, 255), "Revolving_Door": (255, 0, 255),
+    "Rolling_Gate": (192, 192, 192), "Rolling_Shutter_Door": (128, 0, 0), "Door_Window_Combo": (128, 128, 0),
+    "Casement_Window": (0, 128, 0), "Sliding_Window": (128, 0, 128), "French_Window": (0, 128, 128),
+    "Bay_Window": (0, 0, 128), "Single_Bay_Window": (255, 165, 0), "Three_Seat_Sofa": (255, 192, 203),
+    "Single_Seat_Sofa": (100, 149, 237), "Corner_Sofa": (255, 215, 0), "Coffee_Table": (218, 165, 32),
+    "Side_Table": (255, 170, 170), "TV_Cabinet": (170, 255, 170), "Wardrobe": (170, 170, 255),
+    "Dressing_Table": (255, 255, 170), "Nightstand": (170, 255, 255), "Shoe_Cabinet": (255, 170, 255),
+    "Sideboard": (255, 220, 190), "Kitchen_Cabinet": (190, 255, 220), "Bathroom_Cabinet": (220, 190, 255),
+    "Bookshelf": (255, 190, 220), "Dining_Table": (190, 220, 255), "Desk": (220, 255, 190),
+    "Chair": (130, 220, 130), "Stool": (220, 130, 130), "Bench": (130, 130, 220),
+    "Double_Bed": (220, 220, 130), "Single_Bed": (130, 220, 220), "Gas_Stove": (220, 130, 220),
+    "Sink": (150, 50, 50), "Bathtub": (50, 150, 50), "Toilet": (50, 50, 150),
+    "Squat_Toilet": (150, 150, 50), "Vanity_Unit": (50, 150, 150), "Shower_Head": (150, 50, 150),
+    "Mop_Sink": (100, 0, 0), "Rug": (0, 100, 0), "Washing_Machine": (0, 0, 100),
+    "TV": (100, 100, 0), "Refrigerator": (0, 100, 100), "Wall_Mounted_AC": (100, 0, 100),
+    "Cabinet_AC": (75, 75, 75), "Water_Dispenser": (175, 175, 175), "Hair_Dryer": (25, 25, 25),
+    "Microwave": (225, 225, 225), "Grill": (10, 140, 10), "Robot_Vacuum": (140, 10, 10),
+    "Table_Lamp": (10, 10, 140), "Living_Room": (140, 140, 10), "Dining_Room": (10, 140, 140),
+    "Bedroom": (140, 10, 140), "Bathroom": (240, 100, 0), "Balcony": (0, 240, 100),
+    "Entrance": (100, 0, 240), "Storage_Room": (240, 0, 100), "Community_Name": (0, 100, 240),
+    "Community_Gate": (100, 240, 0), "Building_Number": (100, 100, 100), "Floor_Number": (200, 200, 200),
+    "House_Number": (255, 10, 10), "Room_Number": (10, 255, 10)
+}
+
+english_lables = [
+    "Single_Door", "Double_Door", "Sliding_Door", "Doorway_Opening", "Mother_Son_Door", "Rolling_Gate",
+    "Rolling_Shutter_Door", "Revolving_Door", "Door_Window_Combo", "Casement_Window", "Sliding_Window",
+    "French_Window", "Bay_Window", "Single_Bay_Window", "Three_Seat_Sofa", "Single_Seat_Sofa",
+    "Corner_Sofa", "Coffee_Table", "Side_Table", "TV_Cabinet", "Wardrobe", "Dressing_Table",
+    "Nightstand", "Shoe_Cabinet", "Sideboard", "Kitchen_Cabinet", "Bathroom_Cabinet", "Bookshelf",
+    "Dining_Table", "Desk", "Chair", "Stool", "Bench", "Double_Bed", "Single_Bed", "Gas_Stove",
+    "Sink", "Bathtub", "Toilet", "Squat_Toilet", "Vanity_Unit", "Shower_Head", "Mop_Sink", "Rug",
+    "Washing_Machine", "TV", "Refrigerator", "Wall_Mounted_AC", "Cabinet_AC", "Water_Dispenser",
+    "Hair_Dryer", "Microwave", "Grill", "Robot_Vacuum", "Table_Lamp", "Living_Room", "Dining_Room",
+    "Bedroom", "Bathroom", "Balcony", "Entrance", "Storage_Room", "Community_Name", "Community_Gate",
+    "Building_Number", "Floor_Number", "House_Number", "Room_Number"
+]
+
+label_dic = {
+    "单开门": "Single_Door", "双开门": "Double_Door", "移门": "Sliding_Door", "垭口": "Doorway_Opening",
+    "子母门": "Mother_Son_Door", "拉闸门": "Rolling_Gate", "卷闸门": "Rolling_Shutter_Door",
+    "旋转门": "Revolving_Door", "门联窗": "Door_Window_Combo", "平开窗": "Casement_Window",
+    "推拉窗": "Sliding_Window", "落地窗": "French_Window", "飘窗": "Bay_Window",
+    "单面飘窗": "Single_Bay_Window", "三人沙发": "Three_Seat_Sofa", "单人沙发": "Single_Seat_Sofa",
+    "转角沙发": "Corner_Sofa", "茶几": "Coffee_Table", "边几": "Side_Table",
+    "电视柜": "TV_Cabinet", "衣柜": "Wardrobe", "梳妆台": "Dressing_Table",
+    "床头柜": "Nightstand", "鞋柜": "Shoe_Cabinet", "边柜": "Sideboard",
+    "橱柜": "Kitchen_Cabinet", "浴室柜": "Bathroom_Cabinet", "书柜": "Bookshelf",
+    "餐桌": "Dining_Table", "书桌": "Desk", "椅子": "Chair", "凳子": "Stool",
+    "条凳": "Bench", "双人床": "Double_Bed", "单人床": "Single_Bed", "燃气灶": "Gas_Stove",
+    "水槽": "Sink", "浴缸": "Bathtub", "马桶": "Toilet", "蹲便器": "Squat_Toilet",
+    "洗漱台": "Vanity_Unit", "花洒": "Shower_Head", "拖把池": "Mop_Sink", "地毯": "Rug",
+    "洗衣机": "Washing_Machine", "电视": "TV", "冰箱": "Refrigerator",
+    "挂式空调": "Wall_Mounted_AC", "柜式空调": "Cabinet_AC", "饮水机": "Water_Dispenser",
+    "吹风机": "Hair_Dryer", "微波炉": "Microwave", "烧烤架": "Grill",
+    "扫地机器人": "Robot_Vacuum", "台灯": "Table_Lamp", "客厅": "Living_Room",
+    "餐厅": "Dining_Room", "卧室": "Bedroom", "卫生间": "Bathroom", "阳台": "Balcony",
+    "玄关": "Entrance", "储物间": "Storage_Room", "小区名": "Community_Name",
+    "小区大门": "Community_Gate", "楼号": "Building_Number", "楼层": "Floor_Number",
+    "门牌号": "House_Number", "房号": "Room_Number"
+}
+
+
+def parse_seg_results(results, filename):
+    """解析旋转框检测结果"""
+    detect_results = []
+    imageHeight, imageWidth = results[0].orig_shape
+    imagePath = os.path.basename(filename)
+    img_inf = (imagePath, imageWidth, imageHeight)
+
+    segs = []
+    for result in results:
+        xywh = result.boxes.xywh.cpu().numpy()
+        box = result.boxes.cpu().numpy()
+        x_c, y_c, w, h = int(xywh[0, 0]), int(xywh[0, 1]), int(xywh[0, 2]), int(xywh[0, 3])
+        x = int(x_c - w / 2)
+        y = int(y_c - h / 2)
+        x1, y1, x2, y2 = x, y, x + w, y + h  # 左上角顶点和右下角顶点
+
+        ##############
+        points_list = []
+        tlp = (x1, y1)
+        trp = (x2, y1)
+        blp = (x1, y2)
+        brp = (x2, y2)
+        points_list.append(tlp)
+        points_list.append(trp)
+        points_list.append(blp)
+        points_list.append(brp)
+        all_x = [point[0] for point in points_list]
+        all_y = [point[1] for point in points_list]
+        ##############
+
+        segments_xy = result.masks.xy[0]  # 归一化坐标,形状通常是 (N, 2) 的一维数组
+        imageHeight, imageWidth = result.orig_shape
+        seg_points = []
+        length = segments_xy.shape[0]
+
+        # for i in range(length):
+        #     seg_point = (int(segments_xy[i, :][0]), int(segments_xy[i, :][1]))
+        #     seg_points.append(seg_point)
+        # points_array = np.array(seg_points).reshape((-1, 2))
+        # points_array = points_array.astype(np.int32)
+        # pts_for_polylines = [points_array]
+
+        for i in range(length):
+            x, y = (int(segments_xy[i, :][0]), int(segments_xy[i, :][1]))
+            seg_points.append(x)
+            seg_points.append(y)
+
+        yolov_x = [round(x / imageWidth, 6) for x in all_x]
+        yolov_y = [round(y / imageHeight, 6) for y in all_y]
+
+        segs.append({
+            # "bbox": points_list,
+            "bbox": [x1, y1, x2, y1, x2, y2, x1, y2],
+            "seg_points": seg_points,
+            "category": label_dic[result.names[int(box.cls[0])]],
+            "color": COLOR_LIST[label_dic[result.names[int(box.cls[0])]]],
+            "label": f"{int(box.cls[0])} {yolov_x[0]} {yolov_y[0]} {yolov_x[1]}{yolov_y[1]}{yolov_x[2]}{yolov_y[2]} {yolov_x[3]} {yolov_y[3]}",
+            "name": result.names[int(box.cls[0])],
+            "score": float(box.conf[0])
+        })
+    return segs, img_inf
+
+
+models = {}
+
+
+@asynccontextmanager
+async def lifespan(app: FastAPI):
+    # 在应用启动时执行
+    print("应用启动...开始加载模型...")
+
+    models["seg"] = YOLO('../../checkpoints/seg_detect_Panoramic_Home.pt')
+
+    print("模型加载完成!")
+    yield
+    # 在应用关闭时执行 (如果需要)
+    print("应用关闭...")
+    models.clear()
+
+
+app = FastAPI(lifespan=lifespan)
+
+
+@app.get("/")
+def read_root():
+    return {"message": "欢迎使用 YOLO 系列模型部署 API"}
+
+
+@app.post("/seg")  # 假设您将此端点修改为接收 JSON 数据
+async def predict_seg(data: dict):
+    """旋转框检测任务,接收 Base64 编码的图片"""
+    try:
+        # 从 JSON 中获取 Base64 字符串
+        base64_string = data.get("image_data")
+        if not base64_string:
+            raise HTTPException(status_code=400, detail="未找到 'image_data' 字段")
+
+        # 解码 Base64 字符串
+        image_bytes = base64.b64decode(base64_string)
+
+        # 将字节流转换为 PIL.Image 对象
+        image = Image.open(io.BytesIO(image_bytes)).convert("RGB")
+
+        # 使用加载好的模型进行推理
+        # results = models["seg"](image, imgsz=2560)
+        results = models["seg"](image, imgsz=640)
+        segs, imginf = parse_seg_results(results, data.get("filename"))
+
+        content_data = JSONResponse(content={"shapes": segs}).body.decode("utf-8")  # 获取原始JSON字符串
+        data_dict = json.loads(content_data)  # 解析为字典
+        # ✅ 添加新数据到shapes列表
+        data_dict.update({
+            "imageHeight": imginf[2],
+            "imagePath": imginf[0],
+            "imageWidth": imginf[1],
+            "version": "4dage_cul_rel_dis_det_0.0.1"
+        })
+
+        return JSONResponse(content=data_dict)
+    except Exception as e:
+        raise HTTPException(status_code=500, detail=f"处理图片时出错: {str(e)}")
+
+
+if __name__ == "__main__":
+    uvicorn.run("seg_server:app", host="0.0.0.0", port=7000, reload=True)

+ 49 - 0
depoly_cultural relics and furniture/seg_detect_Panoramic_Home/yolov_seg_test.py

@@ -0,0 +1,49 @@
+import os
+
+import cv2
+
+from ultralytics import YOLO
+import numpy as np
+
+# yolov_path = "/media/gu/d54b9541-2b55-4c75-b059-3006d51983d53/lqc/Projects/remove_people/yolov11/ultralytics-main/runs/obb/train5/weights/best_ya.pt"
+
+yolov_path = "/media/gu/d54b9541-2b55-4c75-b059-3006d51983d53/lqc/机房上传文件/ultralytics/train3/weights/best.pt"
+
+model = YOLO(yolov_path)
+
+#################################################################################
+
+img_name = './KJ-vYL6GFH2fYw_30.jpg'
+img = cv2.imread(img_name)
+results = model(source=img_name, imgsz=640)
+for result in results:
+    box = result.boxes.xywh.cpu().numpy()
+    x_c, y_c, w, h = int(box[0, 0]), int(box[0, 1]), int(box[0, 2]), int(box[0, 3]) #矩形框的中心和w,h
+    x = int(x_c - w / 2)
+    y = int(y_c - h / 2)
+
+    x1, y1, x2, y2 = x, y, x + w, y + h  # 左上角顶点和右下角顶点
+
+    segments_xy = result.masks.xy[0]  # 归一化坐标,形状通常是 (N, 2) 的一维数组
+    imageHeight, imageWidth = result.orig_shape
+    seg_points = []
+    length = segments_xy.shape[0]
+    for i in range(length):
+        seg_point = (int(segments_xy[i, :][0]), int(segments_xy[i, :][1]))
+        seg_points.append(seg_point)
+
+    points_array = np.array(seg_points).reshape((-1, 2))
+    points_array = points_array.astype(np.int32)
+    pts_for_polylines = [points_array]
+
+    cv2.polylines(
+        img=img,
+        pts=pts_for_polylines,
+        isClosed=True,
+        color=(0, 0, 255),  # 红色 (BGR)
+        thickness=2,
+        lineType=cv2.LINE_AA
+    )
+    cv2.rectangle(img, (x1, y1), (x2, y2), (255, 0, 0), 3, cv2.LINE_AA)
+    cv2.imwrite('out.png', img)
+    temp = 1