Chien-Hung / ImageRetrievalGUI

Image Retrieval (Metric Learning) GUI
MIT License
6 stars 1 forks source link

Unable to train on a custom dataset. #1

Open Zumbalamambo opened 3 years ago

Zumbalamambo commented 3 years ago

I'm trying to train on a custom dataset and it throws the following error,

 simmat = torch.mm(self.feat, self.data_info.features.T).squeeze()
IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)
Chien-Hung commented 3 years ago

Hello, first of all, this repository is only the inference code for visualizing the image retrieval results. It does not contain the training code. If you want to train, you can refer Deep-Metric-Learning-Baselines, and after training, you need to modify libs/datasets.py and libs/models.py to your custom dataset and model.

Your error means that the input dimension of torch.mm is incorrect, please check the shape of self.feat and self.data_info.features.T.

print(self.feat.shape)
print(self.data_info.features.T.shape)
simmat = torch.mm(self.feat, self.data_info.features.T).squeeze():

They are expected as : self.feat.shape : [1, feature_dim] (ex : [1, 512]) self.data_info.features.T.shape : [feature_dim, image_collection_number] (ex : [512, 110])

If there are any errors, please let me know. Thank you.