GithubHelp home page GithubHelp logo

confusezius / deep-metric-learning-baselines Goto Github PK

View Code? Open in Web Editor NEW
575.0 17.0 91.0 2.92 MB

PyTorch Implementation for Deep Metric Learning Pipelines

License: Apache License 2.0

Python 94.91% Shell 5.09%
pytorch deep-metric-learning deep-learning metric-learning neural-networks computer-vision pku-vehicle distance-sampling shop-clothes cars196 cub200

deep-metric-learning-baselines's Issues

Issue when loading In-Shop Clothes Dataset

Hi, @Confusezius ,

Thanks for your excellent code and for sharing it!

When running

python3.6 Standard_Training.py --gpu 0 --savename resnet_inshop_margin_dist  --dataset in-shop --n_epochs 40 --tau 25 --loss marginloss --sampling distance

the following issue raises and I've put the dataset under Datasets directory and the data is fine.

Getting pretrained weights...
Done.
MARGINLOSS Setup for RESNET50 with DISTANCE sampling on IN-SHOP complete with #weights: 23770304
Traceback (most recent call last):
  File "Standard_Training.py", line 161, in <module>
    dataloaders      = data.give_dataloaders(opt.dataset, opt)
  File "/home/code/Deep-Metric-Learning-Baselines/datasets.py", line 50, in give_dataloaders
    datasets = give_InShop_datasets(opt)
  File "/home/code/Deep-Metric-Learning-Baselines/datasets.py", line 280, in give_InShop_datasets
    train_dataset     = BaseTripletDataset(train_image_dict, opt,   samples_per_class=opt.samples_per_class)
  File "/home/code/Deep-Metric-Learning-Baselines/datasets.py", line 398, in __init__
    transforms.RandomHorizontalFlip(0.5)])
TypeError: object() takes no parameters

So, could u shed me some light? Thanks!

How to save and evaluate model after training ?

I wanted to know how we could save the model weights and use it for inference on some test data ?
I tried using torch.save() and torch.load() after all completion of all epochs, but the results are not similar as to automatic eval on test split and quite bad.
Could you please provide some inputs on this ?

A question to ask

I wanna ensure if the Function recover_closest_one_dataset(line 339 from auxiliaries.py ) which is to recover closest Example Image has relation with each training process(specifically means Kmean' process), Because i found during every testing epoch, the feature_matrix_all seems to be the same,(line 279 from evaluate.py ),and the process of getting one sample' closest samples is achived by faiss.IndexFlatL2 then .add .search. So it means i can get all examples' three closest samples after training the first epoch not after every training epoch?
Looking forward to your reply.

Error while training

Hi there, I'm new in this field and I tried to use my own dataset similar to the CAR dataset structure. I'm running on Windows 10 and I couldn't install faiss , i tried using auxiliaries_nofaiss.py for all the imports, is there any solution to this? the model is able to run for 1 epoch, however, the evaluation part is taking very long time, the report is saying 119 GB, and giving me the error as below:

Any help from anyone would be appreciated. Thanks a lot.

GPU:0, dataset:rp2k, arch:resnet50, embed_dim:128, embed_init:default
loss:fastap, sampling:None, samples_per_class:0, resize256:False
bs:32, lr:1e-05, fc_lr_mul:0, decay:0.0004, gamma:0.3, tau:[20], bnft:False
Running with learning rates 1e-05...
Epoch (Train) 0: Mean Loss [0.0136]: 100%|█████████████████████████████████████████| 4605/4605 [27:19<00:00, 2.92it/s]
Computing Evaluation Metrics...: 100%|█████████████████████████████████████████████| 5585/5585 [07:55<00:00, 13.33it/s]
Traceback (most recent call last):
File "Standard_Training.py", line 365, in
main()
File "Standard_Training.py", line 344, in main
eval.evaluate(opt.dataset, LOG, save=True, **eval_params)
File "C:\Users\user\Documents\DeepMetricLearningBaselines\evaluate.py", line 57, in evaluate
ret = evaluate_one_dataset(LOG, **kwargs)
File "C:\Users\user\Documents\DeepMetricLearningBaselines\evaluate.py", line 279, in evaluate_one_dataset
F1, NMI, recall_at_ks, feature_matrix_all = aux.eval_metrics_one_dataset(model, dataloader, device=opt.device, k_vals=opt.k_vals, opt=opt)
File "C:\Users\user\Documents\DeepMetricLearningBaselines\auxiliaries_nofaiss.py", line 239, in eval_metrics_one_dataset
k_closest_points = squareform(pdist(feature_coll)).argsort(1)[:, :int(np.max(k_vals)+1)]
File "C:\Users\user\anaconda3\envs\kunhe\lib\site-packages\scipy\spatial\distance.py", line 1985, in pdist
dm = np.empty((m * (m - 1)) // 2, dtype=np.double)
MemoryError: Unable to allocate 119. GiB for an array with shape (15967113051,) and data type float64

@
Screenshot 2021-01-29 022502

resizing images to 256x256

transf_list.extend([transforms.RandomResizedCrop(size=224) if opt.arch=='resnet50' else transforms.RandomResizedCrop(size=227),

I believe there's a bug in BaseTripletDataset.transform: during training, images are not resized to 256x256 before taking crops.

Interestingly, this did not seem to affect results by much, at least when I tested it in Online Products with Margin loss...

Question about method 'semihardsampling' of class 'Tuplesampler'

In lines 150 and 152, it seems like the method 'semihardsampling' acts like MS mining('Multi Similarity Loss with General Pair Weighting', CVPR2019), not semi-hard sampling.

neg_mask = np.logical_and(neg,d<d[np.where(pos)[0]].max())
pos_mask = np.logical_and(pos,d>d[np.where(neg)[0]].min())

In terms of similarity, these lines seem equivalent to MS mining with $\epsilon = 0$ to me.
Could you please check it again?

How to make it an inference model?

Hi Author,
May I know which part I should look into if I want to make this an inference mode?

I can modify the code myself. Hope to get some guidance in terms of the part /modules to look into . I'm a bit confused because the whole module is complex.

Use Case:
Input 2 similar / different images, output similarity score or a MATCH/Not MATCH result.

Regards,
Alex

RuntimeError: CUDA out of memory.

I cloned the repo, ran the install.sh script and tried running the Standard_Training.py file, but as soon as the network starts training, I get the error

RuntimeError: CUDA out of memory. Tried to allocate 42.88 MiB (GPU 0; 7.79 GiB total capacity; 6.35 GiB already allocated; 46.38 MiB free; 601.50 KiB cached)

I am using a 2070 Super GPU with 8 GB of vram. Is this too little to run the baseline, or do you think there is some other problem?

Thank you in advance

Evaluation on SOP took forever

Hi
Thank you for your work and code!

I tested on CUB and CAR and it worked well but when I used SOP dataset, it seemed as it got stuck in the evaluation process, right inside the calculation of kmeans. The test values of Epoch 0 never got out and the program just got stuck there. It was the same for faiss or no_faiss setting.

Did I miss anything or could you suggest some hints to solve it?

Cheers

is the file 'pretrainedmodels.py' missing?

File "Deep-Metric-Learning-Baselines/netlib.py", line 21, in <module> import pretrainedmodels as ptm ModuleNotFoundError: No module named 'pretrainedmodels'

I run the code then get the problem, Thank you very much for your help.

Question on Proxy-NCA

Hi, thanks for the nice code. I noticed that your re-implementation of the Proxy-NCA is much higher than that from their original paper on CUB-200, e.g. R@1= 64.0 vs R@1= 49.

I understand that the original paper uses Inception, and you train a ResNet50, are the performance boost all from architecture ? Or is there any other implementation differences ?

Version of in-shop dataset

Hi
just wondering which version of in-shop dataset did you use? Since there are two versions in the page (one normal and one high resolution) and the high resolution one needs a password.

Thanks

about the organization of Cars196

hello, I want to reproduce your result on Cars196, but when i download the dataset from the official website, the organization of the dataset doesn't like the one you provide in the readme. Could you please provide a hint or the code of how to handle these data. Thanks :)

If I understand your code correctly...

Hello sir,

In the file 'auxiliaries.py', line 391:

sample_idxs = np.random.choice(np.arange(len(gallery_feature_matrix_all)), n_image_samples)

If I understand your code correctly, should 'gallery_feature_matrix_all' be 'query_feature_matrix_all'?

Thanks

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.