Parcourir la source

fix the python environment path problem

MaochengHu il y a 2 ans
Parent
commit
d25269c4af
1 fichiers modifiés avec 16 ajouts et 4 suppressions
  1. 16 4
      src_code/test/test_src/yolo_test_handler.py

+ 16 - 4
src_code/test/test_src/yolo_test_handler.py

@@ -7,8 +7,19 @@
 
 import sys
 import os
-print(os.getcwd())
-sys.path.append("../../src")
+root_src = "../../src"
+
+
+
+def import_env(names):
+    for name in names:
+        sys.path.append(os.path.join(os.getcwd(), name))
+
+
+append_path = ["../../src/server_utils", "../../src/", "../../src/model_structure",
+               "../../src/model_structure/yolov5_structure/yolov5-master"]
+
+import_env(append_path)
 from server_utils.image_convert import path2base64
 from object_detector_handler import ObjectDetectionHandler
 
@@ -18,8 +29,9 @@ def main():
     test_source = "../test_images/test1.jpg"
     base64str = path2base64(test_source)
     context = None
-    output_methods = ["pd_xywh_json", "pd_xywhn", "pd_xyxy", "pd_xyxyn", "tolist", "crop_np", "crop_base64",
-                      "detail_time_info", "render_base64"]
+    # , "pd_xywhn", "pd_xyxy", "pd_xyxyn", "tolist", "crop_np", "crop_base64",
+    #                       "detail_time_info", "render_base64"
+    output_methods = ["pd_xywh_json"]
     obh = ObjectDetectionHandler()
     data = {"data": base64str, "output_methods": str(output_methods).encode(), "base64_bool": str(True).encode()}
     result = obh.handle([data], context)