BGU-CS-VIL / DeepDPM

"DeepDPM: Deep Clustering With An Unknown Number of Clusters" [Ronen, Finder, and Freifeld, CVPR 2022]

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

--pretrain_path parameter and how custom data should be shaped

ilisparrow opened this issue · comments

Hello,
Thank you very much for sharing your work.

I am trying to use your code to classify images on acustom dataset.

Somethings are still a bit unclear.

I went for the feature+clustering way, I can't seem to make sense of the pretrain_path parameter.

If I want to use the Umap extractor what should I replace it with ?

The second question being, Would this as a generic custom class fit :

class Custom(MyDataset):
    def __init__(self, args):
        super().__init__(args)
        self.transformer = transforms.Compose([transforms.ToTensor(),    transforms.Resize((28,28)), transforms.Normalize((0.1307,), (0.3081,))])
        self._input_dim = 28 * 28

    def get_train_data(self):
        return datasets.Custom(self.data_dir, train=True, download=False, transform=self.transformer)

    def get_test_data(self):
        return datasets.Custom(self.data_dir, train=False, transform=self.transformer)

And in which format should the training data be ?

THank you very mluch in advance !

Dear @ilisparrow,
If you want to use UMAP for feature extraction, you should first use UMAP offline (by yourself) to generate the features in a lower dim and then save them in .pt files (see the files in umap_embedded_dataset dir for examples). DeepDPM expects to get flattened features (i.e., N X D tensors with N = number of points and D - features dimension).
Our code for feature extraction supports only using an autoencoder for that, for which you will need to define the "--latent_dim" argument, which will be the latent features' dim.

Then, you can load the features using the code you suggested, but note that _input_dim should be the features' latent dim (for both the UMAP or the AE extracted features).

We will soon upload a code update with easier custom dataset loading, but in the meantime using what you suggested would make sense.

The --pretrain_path refers to the path of the pretrained AE weights. Note that if your data is different from the datasets we trained our AE on, you should not use the pretrained weights, and train an AE for your own data (you can do that using our code).