bubbliiiing / Siamese-pytorch

这是一个孪生神经网络(Siamese network)的库,可进行图片的相似性比较。
MIT License
539 stars 120 forks source link

some bug in dataloader about the self.types ? #17

Open Peter-weng opened 1 year ago

Peter-weng commented 1 year ago

hello,i meet some problem when i frist time run the code. error:

   different_c_index   = np.random.choice(range(0, self.types - 1), 1)
  File "mtrand.pyx", line 915, in numpy.random.mtrand.RandomState.choice
ValueError: 'a' cannot be empty unless no samples are taken

i think the self.types may be the size of labels,so i change the code and work for me like this,

class SiameseDataset(Dataset):
    def __init__(self, input_shape, lines, labels, random, autoaugment_flag=True):
        self.input_shape    = input_shape
        self.train_lines    = lines
        self.train_labels   = labels
        self.types          = labels.size    #  max(labels)

maybe is difficult version env make this problem?

bubbliiiing commented 1 year ago

Your dataset format is wrong. There is a train_own_datasets parameter in train.py needs to be set.

Peter-weng commented 1 year ago

fine,i set train_own_datasets = True,which dataset format wrong? i used DDP in 8*3090 but i think it slow about dataloader,would you like to add cache image function in training like yolov5?

bubbliiiing commented 1 year ago

Can you start training now? I set two data formats, corresponding to different data sets. The original data format corresponds to the omniglot dataset. I don't set cache, but I think you can improve num_ works.

Peter-weng commented 1 year ago

yeah, i can train now and finish the cache function,thanks for your reply

bubbliiiing commented 1 year ago

3q