I have a custom model which requires some manipulation of the image and creation of a specific tensor that feeds into the inference blob. How do I accomplish this in the pipeline?
create a vector for input to custom model
Hi RichardBarclay
You can do this by calling setLayer()
method on NNData. https://docs.luxonis.com/projects/api/en/latest/references/python/#depthai.NNData.setLayer.
Hope this helps,
Jaka
Looking at the documents the set layer seems to offer very stransformation. The transformation I need to make is as follows (from code to feed ONNX version of the NN):
def image_transform_onnx(path: str, size: int) -> np.ndarray:
image = Image.open(path)
image = image.resize(300,300) # will not neeed
image = np.array(image)
image = image.transpose(2,0,1).astype(np.float32)
image /= 255
image = image[None, ...]
return image
Hi RichardBarclay
I think you might be able to apply all these functions before you compile your model to blob. (Source https://docs.luxonis.com/en/latest/pages/tutorials/deploying-custom-model/#model-optimizer-parameters)
Thoughts?
Jaka
thanks, I will take a look at that, I was thinking I might need a script node