Jelajahi Sumber

修改图像分类模型推理流程

liyan 2 bulan lalu
induk
melakukan
efeecf5eb4
1 mengubah file dengan 2 tambahan dan 1 penghapusan
  1. 2 1
      watermark_verify/inference/classification_inference.py

+ 2 - 1
watermark_verify/inference/classification_inference.py

@@ -55,7 +55,8 @@ class ClassificationInference:
         img = Tensor(image[None, :, :, :])
         model = base.model(modelPath=self.model_path)  # 初始化 base.model 类
         outputs = model.infer([img])[0]  # 执行推理。输入数据类型:List[base.Tensor], 返回模型推理输出的List[base.Tensor]
-        outputs = np.array(outputs.to_host())  # 将outputs移动到内存中,并且将base.Tensor类转为numpy array
+        outputs.to_host()
+        outputs = np.array(outputs)  # 将outputs移动到内存中,并且将base.Tensor类转为numpy array
         return outputs
 
     def predict_batch(self, image_paths):