Giter VIP home page Giter VIP logo

deep_metric's People

Contributors

bnu-wangxun avatar ppwwyyxx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deep_metric's Issues

Using resnet50 as base network

I have been trying Resnet 50 as the training network, however, it ends up errors saying there is no embed parameters, I am wondering what are changes needed to make in order to use it in your framework?

problem about the result

Hello, thanks for your good jobs!
When I use your codes, i find almost all types of loss can reach the result that rank1 is over 0.60. But when i read the paper, if the method is over 0.60(rank1), it can be seen as a good method. Even the contrastive loss can achieve rank1 over 0.60. Why? Thanks

About the Binomial Deviance Loss

Thank you for sharing your code. Nice work! I have a question about the Binomial Deviance Loss. In your previous paper, Binomial without mining achieves recall-top1 of 64% on CUB200, but I can not reproduce the result with your code. Could you provide more detail about your implementation? For example, the alpha and beta.

About the hyper parameters of weight loss

Hey, thank you for uploading your code and sharing your work.I tried running your code, but the result is not good as that given in your paper.At first,I thought it was a hyper parameter(alphabet and base) problem as the parameters set in the code were inconsistent with those in the paper.I tried to run the code according to the parameters in the paper, and found that the result were worse.Could mind sharing the best hyper parameters of the weight loss(alpha=?,beta=?,base=?),thank u very much!

Reference of the losses?

Hello :D Thanks for your sharing!
I actually just started this metric learning few weeks ago, so I couldn't recognize the reference of those losses. Could you let me know the reference of the 'Weighted' Loss, and Margin loss?
Thanks

Result Analysis Request

I start studying for the first time. Please analyze the results.
And why is the accuracy zero?
train===
Epoch: [001][1/1] Time 2.391 Loss 5.4381 Accuracy 0.0000 Pos 0.6235 Neg 0.6207

why use a alpha in NCALoss ?

Hi, i have a question about the alpha which is a Hyperparameter

base = torch.mean(dist_mat[i]).data[0]

计算logit, base的作用是防止超过计算机浮点数

pos_logit = torch.sum(torch.exp(self.alpha*(base - pos_neig)))
neg_logit = torch.sum(torch.exp(self.alpha*(base - neg_neig)))
loss_ = -torch.log(pos_logit/(pos_logit + neg_logit))

In your implementation, I found that you first used K-nearest neighbors to select negative samples and then calculated the mean of the distances.
Maybe because the result is too small, so multiply by a parameter alpha?

TypeError: unsupported format string passed to Variable.__format__

Traceback (most recent call last):
File "train.py", line 207, in
main(parser.parse_args())
File "train.py", line 121, in main
optimizer=optimizer, train_loader=train_loader, args=args)
File "/home/user/2T-G/zyy/Deep_metric-master/trainer.py", line 62, in train
loss=losses, accuracy=accuracy, pos=pos_sims, neg=neg_sims))
TypeError: unsupported format string passed to Variable.format
I have encountered the above problem, can you help me solve it? Thanks

Problem about SemiHardLoss

Thank you for sharing your code.It help me a lot to know DML.I've been looking at SemiHard for the last two days, but the papers that the project cites don't seem to go into it in detail.
Could you please tell me some specific information about SemiHard or the corresponding articles?Thx a lot.

CUB dataset train.txt and test.txt file issues

Hey, thank u very much for uploading your great work!
I got a small problem about reading your train.txt and test.txt files in Dataset folder. Firstly, it seems like u haven't uploaded any test.txt file. Secondly, for different dataset, the train and test txt files should be different, right?
Did u forget to upload it or am I miss understanding ur work?
thank u very much again!
cheers

trainloader issues

Hey I saw you updated your work recently, that is so nice of you.

I got a question about trainloader here. As I posted before, when I ran your code on my own computer, the loss function is increasing. The problem may be the trainloader. I found that in each epoch, the train loader only load about 480 images which is strange. The number of iterations in each epoch is only 6. I was trying to fix it by myself but it looks a little bit difficult to fully understand your code. Do you have any suggestions for me to fix this problem?

Cheers
Candice

Pretrained models

Hi,
Thanks for your great work! But it seems that the pre-trained models were removed from the cloud drive. Could you please kindly upload them again ?

Distance weighted margin loss

Hi, I wonder if you also tried the distance weighted margin loss specified in Sampling Matters in Deep Embedding Learning.

I see you have the sampling scheme applied to deviance loss. I wonder why?

About dataset

Where can i get the train.txt and test.txt in Product and In-shop Clothes Retrieval Benchmark dataset?Thanks

For the losses in your code

Thanks for sharing your great work!
I read some questions and your answers about the losses, but I ask again to make it sure.
For the losses in your code, I see a similar type of losses such as
neg_loss = 2.0/self.alpha * torch.log(1 + torch.sum(torch.exp(self.alpha * (neg_pair - base))))
from the SemiHard loss, DistWeighted loss. As far as I know, those losses were a linear loss of the distance(in your code, similarity) according to the original papers. (If those losses are from the FaceNet and Sampling matteres...)
Are these losses your own 'Weight' loss which has an assumption that the data follows the distribution of the mixture of Gaussian?
Thanks :D

Hyperparams for npair and nca

Does your code reproduce the R@1 on cars-196 using npair (71.1) and proxy-nca (73)? If yes could you please share the hyperparams please?

About the implementation of 'lr_mul' trick

Hello! I meet a problem when i am reading your code; Specifically, that is the implementation of 'lr_mul' trick.
your implementation of it is as follows:
param_groups = [ {'params': base_params, 'lr_mult': 0.0}, {'params': new_params, 'lr_mult': 1.0}]

And in the open-source code of your MS loss :
the implementation of it is as follows:
def build_optimizer(cfg, model): params = [] for key, value in model.named_parameters(): if not value.requires_grad: continue lr_mul = 1.0 if "backbone" in key: lr_mul = 0.1 params += [{"params": [value], "lr_mul": lr_mul}] optimizer = getattr(torch.optim, cfg.SOLVER.OPTIMIZER_NAME)(params, lr=cfg.SOLVER.BASE_LR, weight_decay=cfg.SOLVER.WEIGHT_DECAY) return optimizer

but in https://pytorch.org/docs/master/optim.html, the implementation of 'lr_mul' is as follows
optim.SGD([ {'params': model.base.parameters()}, {'params': model.classifier.parameters(), 'lr': 1e-3} ], lr=1e-2, momentum=0.9)

I want to know is there any difference between 'lr_mul' and 'lr_mult'? I can find any information of that. And in the document of pytorch framework, I cannot find any explain of 'lr_mul' and 'lr_mult'. (I find that the 'lr_mult' is used in caffe framework.) I'm confused of this problem and I need your help.
Thank you!

Great work, could you share some performance comparisons of your implementation?

It is very good to keep such a repo to summarize all the metric learning related loss functions' implementation. I am wondering whether it is convenient for you to share us the evaluation results to get more insights about whether your implementation is comparable with their orignal implementations.

Besides, you mentioned that your method named below has achieved state-of-the-art performance.

New Positive Mining Loss based on Fuzzy Clustering

Have you compared your method with some recent work like HDC[1], BIER[2] and so on.

[1] : Yuan Y, Yang K, Zhang C. Hard-Aware Deeply Cascaded Embedding[J]. arXiv preprint arXiv:1611.05720, 2016.
[2]: Opitz, Michael, et al. "BIER-Boosting Independent Embeddings Robustly." Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. 2017.

Where to download your paper?

Hey, thank you very much for your code. I know that this work has been accepted by CVPR2019, and have you release the work on arxiv? Where can I download your work. Thanks.

XBM code regarding

Hey when would the XBM code be released ? Is it possible to get it before you post it here (If it takes time) ? Thanks !

Question of Rank@k and Top@k

I have scanned the code of evalutions and now am confused of the metric 'rank@k'.
Is it the same with metric 'top@k'?

I revised the script 'test.py' and add additional functions to get the metric 'top@k'.
As you know, the two metrics are obtained from the matrix 'sim_mat' which is provided by you.
But the results of them are not equal sometimes.

So, could you explain the concept of 'recall@k' in the view of your code?

Thank you very much.

BUG in preprossing image

In "CUB200.py" file, function "Generate_transform_Dict", It seems that the mean and std should be set to mean = [0.485, 0.456, 0.406] and std = [0.229, 0.224, 0.225] in RGB setting. And I have a question about your convertBGR, it seems that you don not use OpenCV. What is this operation mean?

cannot reproduce the result you reported

By running the code, first training and then test, without changing anything. I got the results below, which are far from being comparable with what you have reported. I use pytorch 0.2.0.4. Any idea on how this happens. Thanks.

test cub***knnsoftmax-model.pkl
[0.48176907 0.61428089 0.74257259 0.84689399]
test cub***knnsoftmax-50_model.pkl
[0.48041864 0.62187711 0.74206617 0.84351789]
test cub***knnsoftmax-100_model.pkl
[0.5035449  0.63740716 0.763842   0.85651587]
test cub***knnsoftmax-200_model.pkl
[0.50303849 0.63723835 0.76164754 0.86090479]
test cub***knnsoftmax-300_model.pkl
[0.50607698 0.6424713  0.76991897 0.86326806]
test cub***knnsoftmax-350_model.pkl
[0.51147873 0.65124916 0.76890614 0.86613774]
  train cub***knnsoftmax-350_model.pkl
[0.58202592 0.696794   0.7941678  0.86834925]
test cub***knnsoftmax-400_model.pkl
[0.5140108  0.64804186 0.77211344 0.86664416]
test cub***knnsoftmax-450_model.pkl
[0.51367319 0.65563808 0.77211344 0.86647535]
test cub***knnsoftmax-500_model.pkl
[0.51536124 0.6492235  0.77599595 0.86866982]
test cub***knnsoftmax-550_model.pkl
[0.51958136 0.65563808 0.7744767  0.86293045]
test cub***knnsoftmax-600_model.pkl
[0.52160702 0.65698852 0.77970966 0.87002026]
  train cub***knnsoftmax-600_model.pkl
[0.62772851 0.73328786 0.82213506 0.88847203]

XBM memory management after detach() operation

I have a question about the algorithm01 in your paper.
You mentioned that the embeddings (called anchors) are detached from the graphe before being put into the queue.
You know that detached nodes from the graph don't retain the gradient history, hence, the embeddings will be considered constants in the next iteration, making them irrelevant to the loss function.
I don't undestand how the gradient can still be calculated on old batches without retaining the gradient history in different stages of the forward pass ?

Thank you.

Proxy-NCA loss

Hi, awesome work!

Have you ever had a chance to reproduce results for Proxy-NCA loss?

Thx

about weight loss

I appreciate your work very much. When I read your source code, I found that the code for weight loss was not released. May I ask when will it be released

problem about contrastive loss

hello, thanks for you work, I'm curious that why you use similarity mat rather than euclidean metirc in contrastive loss and triplet loss.

modified lifted loss

Thanks for the comprehensive implementation. Really helpful for understanding the various metric learning loss.

I'm wondering if you can shed some insights on the modified loss function, which takes a different formation as the original one.

Compared to the original loss, the modified version use a different pos loss, and introduce a new parameter beta.

when I load the pretrained_model, the shape of weights always mismatch

Traceback (most recent call last):
File "train.py", line 184, in
main(parser.parse_args())
File "train.py", line 41, in main
model = models.create(args.net, pretrained=True, dim=args.dim)
File "D:\ProgramData\pyProjects\Pytorch-Deep-metric\models_init_.py", line 22, in create
return __factory[name](*args, **kwargs)
File "D:\ProgramData\pyProjects\Pytorch-Deep-metric\models\BN_Inception.py", line 521, in BN_Inception
model.load_state_dict(model_dict)
File "D:\Program Files\Anaconda3\envs\pytorch1\lib\site-packages\torch\nn\modules\module.py", line 769, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for BNInception:
size mismatch for conv1_7x7_s2_bn.weight: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for conv1_7x7_s2_bn.bias: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for conv1_7x7_s2_bn.running_mean: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).

How to solve this problem?

performace of triplet loss

Hello! Have you ever reproduced the results for triplet loss or N-pair loss? I found that the performace of ImageNet pretrained model is even better than the model further trained with triplet loss on CUB or CAR.

Do different pre-trained models have a big impact

I tried to replace the BN-inception with resnet50 pretrained on imagenet.
it seems that the performence droped a lot.
With your code, I can reproduce the result on cub-200, about 0.65.
And I inplemented a gluon(mxnet) version of the binomial loss.
But i can't find the pretrained model on mxnet.
Therefor, I tried different pretrained models. And the performences varies from 0.50 - 0.60 on cub-200.
Thus, I wonder know if different models have a big impact on the permformece?
Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.