Replace an easy way to construct a `ncnn.Mat` (#3638)

pull/3655/head^2
triple Mu 1 year ago committed by GitHub
parent 495edc261f
commit 82920ef7ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      ultralytics/nn/autobackend.py

@ -372,10 +372,7 @@ class AutoBackend(nn.Module):
self.predictor.run()
y = [self.predictor.get_output_handle(x).copy_to_cpu() for x in self.output_names]
elif self.ncnn: # ncnn
im = (im[0] * 255.).cpu().numpy().astype(np.uint8)
im = np.ascontiguousarray(im.transpose(1, 2, 0))
mat_in = self.pyncnn.Mat.from_pixels(im, self.pyncnn.Mat.PixelType.PIXEL_RGB, *im.shape[:2])
mat_in.substract_mean_normalize([], [1 / 255.0, 1 / 255.0, 1 / 255.0])
mat_in = self.pyncnn.Mat(im[0].cpu().numpy())
ex = self.net.create_extractor()
input_names, output_names = self.net.input_names(), self.net.output_names()
ex.input(input_names[0], mat_in)

Loading…
Cancel
Save