-
Notifications
You must be signed in to change notification settings - Fork 140
Open
Description
I used the following image for inference and received two different results.
With cv2:
image = cv2.imread("path/to/image")
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image_resized = cv2.resize(image_rgb, (128, 32), interpolation=cv2.INTER_CUBIC)
image_tensor = torch.from_numpy(image_resized).float()
image_tensor = image_tensor.permute(2, 0, 1)
image_tensor = (image_tensor / 255.0 - 0.5) / 0.5
image = image_tensor.unsqueeze(0).cuda()
image = to_numpy(image)
outputs = ort_sess.run(None, {input_tensor.name: image})
logits = torch.from_numpy(outputs[0])
output = logits.softmax(-1)
pred, conf_scores = token_decoder.decode(output)
The result is: ['NORTIS']
With PIL.Image:
target_transform = transforms.Compose([
transforms.Resize((32, 128), transforms.InterpolationMode.BICUBIC),
transforms.ToTensor(),
transforms.Normalize(0.5, 0.5)
])
image = Image.open("path/to/image").convert("RGB")
image = target_transform(image).unsqueeze(0).cuda()
image = to_numpy(image)
outputs = ort_sess.run(None, {input_tensor.name: image})
logits = torch.from_numpy(outputs[0])
output = logits.softmax(-1)
pred, conf_scores = token_decoder.decode(output)
The result is: ['SALMON']
Metadata
Metadata
Assignees
Labels
No labels