Parcourir la source

解决运行测试脚本找不到watermark_verify库的问题

liyan il y a 1 semaine
Parent
commit
e4fd41ce04

+ 3 - 0
tests/classification_performance_loss_test.py

@@ -5,6 +5,9 @@ pip install psutil gputil pynvml
 """
 import argparse
 import os
+import sys
+rootpath = str(os.path.abspath(os.path.join(os.path.dirname(__file__), '../')))
+sys.path.append(rootpath)
 
 import psutil
 import GPUtil

+ 3 - 0
tests/detection_performance_loss_test.py

@@ -5,6 +5,9 @@ pip install psutil gputil pynvml pycocotools
 """
 import argparse
 import os
+import sys
+rootpath = str(os.path.abspath(os.path.join(os.path.dirname(__file__), '../')))
+sys.path.append(rootpath)
 
 import psutil
 import GPUtil

+ 4 - 0
tests/inference_test.py

@@ -1,3 +1,7 @@
+import os
+import sys
+rootpath = str(os.path.abspath(os.path.join(os.path.dirname(__file__), '../')))
+sys.path.append(rootpath)
 from watermark_verify.inference.rcnn_inference import FasterRCNNInference
 from watermark_verify.inference.ssd_inference import SSDInference
 from watermark_verify.inference.yolox_inference import YOLOXInference

+ 3 - 0
tests/verify_tool_accuracy_test.py

@@ -4,6 +4,9 @@
 
 import argparse
 import os
+import sys
+rootpath = str(os.path.abspath(os.path.join(os.path.dirname(__file__), '../')))
+sys.path.append(rootpath)
 
 from watermark_verify import verify_tool
 

+ 5 - 1
tests/verify_tool_test.py

@@ -1,9 +1,13 @@
 """
 支持所有待测模型,测试模型水印提取功能,对提供的指定模型文件进行水印检测
 """
+import os
+import sys
+rootpath = str(os.path.abspath(os.path.join(os.path.dirname(__file__), '../')))
+sys.path.append(rootpath)
 from watermark_verify import verify_tool
 
 if __name__ == '__main__':
-    model_filename = "/mnt/e/DevTools/workspace/model_watermark_detect/tests/models/blackbox/alexnet/alexnet.onnx"
+    model_filename = "/mnt/e/DevTools/workspace/model_watermark_detect/tests/models/blackbox/yolox/yolox.onnx"
     verify_result = verify_tool.label_verification(model_filename)
     print(f"verify_result: {verify_result}")