Created
May 7, 2022 09:34
-
-
Save sachadee/6e71c946dcc4c97948068df05f8c81c2 to your computer and use it in GitHub Desktop.
final
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with torch.no_grad(): | |
for idx, (image, _) in enumerate( | |
tqdm(loader, desc="Create embeddings matrix", total=len(loader)), | |
): | |
embeddings = np.empty([1,512]) | |
embeddings[int(0) :] = F.normalize(backbone(image.to(device))).cpu() | |
image = image[0].permute(1,2,0) | |
imgarr = image.cpu().detach().numpy() | |
print(imgarr.dtype) | |
opencvImage = cv2.cvtColor(imgarr, cv2.COLOR_RGB2BGR) | |
opencvImage = cv2.normalize(opencvImage, None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8U) | |
print(opencvImage.dtype) | |
cv2.imshow('test',opencvImage) | |
cv2.waitKey(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment