Open mahfujau opened 6 years ago
The samples of three files, XXX_train_lmdb_pos1/pos2/neg, are one-to-one correspondding, which can be used as a triplet for our triplet loss. For example, the three 9th images in XXX_train_lmdb_pos1/pos2/neg form the 9th triplet sample. For the binary classification loss, the sample contains two images. The corresponding two images in XXX_train_lmdb_pos1/pos2 form a positive sample, and the corresponding two images in XXX_train_lmdb_pos1/neg form a negative sample. And the labels in XXX_train_lmdb_pos2/neg are used to be sent to binary classification loss as sample labels.
Thank you so much for your reply. Is there any way to classify for multiple categories. For an example: we have different images from 7 categories such as: Pen Computer Book Paper Backpack Pencil Bottle
How we can classify these images using triplet loss?
Your problem is a classification issue, i suggest you use a softmax cross entropy loss to solve this issue. If you insist to try the triplet loss, you can build the sample with three images, called a triplet, (img_i_a,img_j_a,img_k_b), where i,j,k are the index of images in their categories, and a,b are the name of categories. img_i_a,img_j_a are two images from the same category, and img_k_b is another image from a different category.
Hi! Thank you so much for this work. I have a dataset which consists of 7 classes. I want to use your code to classify my data. How can I make datasets labeling?
For an example, you preprocess the images for binary classification:
XXX_train_lmdb_pos1: all images label are 0
XXX_train_lmdb_pos2: all images label are 1
XXX_train_lmdb_neg: all images label are 0
XXX_valrank_lmdb_pos: all images label are 0 except the first image which label is 1
XXX_valrank_lmdb_neg: all images label are 0 except the first image which label is 1
How can we label our images if the total classes are 7? Thank you so much.