Skip to content
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

about the similar result compare #18

Open
Usernamezhx opened this issue Apr 30, 2021 · 0 comments
Open

about the similar result compare #18

Usernamezhx opened this issue Apr 30, 2021 · 0 comments

Comments

@Usernamezhx
Copy link

thanks for you work. I test pair image by the model:imagenet_64bit_0.8734_resnet50.pkl. and get the hamming distance:0
This is my test code:

class CSQ(object):
    def __init__(self):
        self.model_path = 'checkpoint/imagenet_64bit_0.8734_resnet50.pkl'
        self.device = "cuda" if torch.cuda.is_available() else "cpu"
        self.transform = prep.image_test(resize_size=255, crop_size=224)
        self.load_model()

    def load_model(self, ):
        self.model = torch.load(self.model_path)
        self.model = self.model.module
        self.model.to(device=self.device)
        self.model.eval()

    def forward(self, img_path):
        tensor_img = self.transform(Image.open(img_path).convert('RGB')).unsqueeze(0).to(self.device)
        with torch.no_grad():
            out = self.model(tensor_img)

        hash_code = out.cpu().numpy()
        hash_code[hash_code < 0] = -1
        hash_code[hash_code >= 0] = 1

        code_list = ''.join(['1' if item == 1.0 else '0' for item in hash_code[0].tolist()])
        return code_list

BWWyelZSGvyJldWl8PnfjqLQdYGJL
WvZq4g2S5z4k5e4Po5zxCGV5yO4PWJ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant