Replies: 1 comment 2 replies
-
Separating the model into "trunk" and "embedder" components can be helpful conceptually (see discussion #270). Other than that, there's nothing special about the two terms. The convention in this library is that
Usually the last layer of these pretrained models is for classification, so before training you should replace the last layer with
Good question. Yes you can provide a custom As for the If you're thinking of taking the 5 crops and computing the average embedding, then you might want to write a custom tester and modify For example, something like: from pytorch_metric_learning.testers import GlobalEmbeddingSpaceTester
from pytorch_metric_learning.utils import common_functions as c_f
class CustomTester(GlobalEmbeddingSpaceTester):
def get_embeddings_for_eval(self, trunk_model, embedder_model, input_imgs):
input_imgs = c_f.to_device(
input_imgs, device=self.data_device, dtype=self.dtype
)
# from https://pytorch.org/vision/stable/transforms.html#torchvision.transforms.FiveCrop
bs, ncrops, c, h, w = input_imgs.size()
result = embedder(trunk(input_imgs.view(-1, c, h, w))) # fuse batch size and ncrops
result_avg = result.view(bs, ncrops, -1).mean(1) # avg over crops
return result_avg
I found this related work: https://hal.archives-ouvertes.fr/hal-03260782/document |
Beta Was this translation helpful? Give feedback.
-
Hi there,
First of all, thanks for the excellent library! Since the documentation is so lovely, it's a pleasure to work with it.
I want to distinguish between papyri-fragments for my project. I use the nearest neighbors based on accuracy for evaluation. To do so, I adapted the MNIST-Example.
I would also be very thankful if you could suggest literature, tutorials, or similar.
Hard facts about my product:
Beta Was this translation helpful? Give feedback.
All reactions