-
Notifications
You must be signed in to change notification settings - Fork 650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lower accuracy when i use djl api to inference #964
Comments
public static BufferedImage toGray(BufferedImage srcImg){ |
Can you try to test with dummy NDArray? Like
If these result are consistent. then it means the preprocessing we have done on PyTorch and DJL are different. Another way to verify that, is to compare the tensor/NDArray before we feed for inference. |
@mengpengfei
Your toGray() will re-render the image with shifted color space, |
@mengpengfei
|
Change-Id: I3e7ae2731d4ad36e3cbe27ec4a2ebd0bc3749ccd
djl api:
BufferedImage read = ImageIO.read(new File("D:\code\SiameseNetwork\a.jpg"));
BufferedImage bufferedImage = toGray(read);
BufferedImage subimage = bufferedImage.getSubimage(0, 0, 60, 60);
NDArray imageArray =
ImageFactory.getInstance()
.fromImage(subimage)
.toNDArray(manager,Image.Flag.GRAYSCALE)
.expandDims(0).transpose(new int[]{0, 3, 1, 2})
.toType(DataType.FLOAT32, true);
python api:
img=cv2.imread(str, cv2.IMREAD_UNCHANGED)
gray=cv2.cvtColor(img,cv2.IMREAD_COLOR)
cropped = gray[0:config.input_h, 0:int(config.input_w/2)]
image0 = torch.from_numpy(np.asarray(cropped)).type(torch.FloatTensor).to(DEVICE)
i got the values of image0 by python api,and i got the values of imageArray by djl api
but the values of imageArray is diffrent with the values of image0
This problem leads to lower accuracy when i use djl api
The text was updated successfully, but these errors were encountered: