wenbinlee / dn4 Goto Github PK
View Code? Open in Web Editor NEWPytorch code of "Revisiting Local Descriptor based Image-to-Class Measure for Few-shot Learning", CVPR 2019.
License: Other
Pytorch code of "Revisiting Local Descriptor based Image-to-Class Measure for Few-shot Learning", CVPR 2019.
License: Other
When** I Try to run your code i get this error
File Not Found Error: [Errno 2] No such file or directory: '/Datasets/CubBirds--ravi/train.csv'
what is ravi in that? why you used ravi ?
only instead of miniImagenet i used cub-200
(parser.add_argument('--dataset_dir', default='/Datasets/miniImageNet--ravi', help='/miniImageNet'))
Hi @WenbinLee ,
Great work. I'm writing a bachelor thesis on improving few-shot learning through data augmentation and it references your paper. Could I ask you to provide the code for plotting the following figures that you made in the paper. It would be very much appreciated!
你好,训练的时候,就用测试集做验证,会不会导致模型提前见到这些数据,一直很苦恼这个问题
Sorry to bother you but I have trained the 5-way 1-shot model (Conv-64F) from scratch and found the avearge test accuracy is 46.63±0.80% which is lower than the results provided in the paper.
I didn't modify the code. The dataset and the split csv files I used are provided by RelationNet (https://github.com/floodsung/LearningToCompare_FSL). Is there something wrong in the dataet processing or any other aspects?
Thanks for your attention.
作者您好!上次有关代码报错的issue非常感谢您能及时的回复,我是可以跑通backbone为Conv64F的模型的。
但是本周我在细粒度数据集StanfordDogs上重新跑了一下2019版本的模型,训练完毕以后经过测试发现5way1shot和5way5shot任务的准确率都比论文中的准确率有大幅度提高,但我并没有对代码进行修改,不知道这是什么情况呢?
backbone为Conv64F,论文中的5way1shot和5way5shot的准确率分别为45.41±0.76和63.51±0.62:
我对该模型重新进行训练以及测试后,5way1shot和5way5shot的准确率分别为51.44和72.92:
Hi, thanks for your cool work. I have a question about Stanford_Cars.
I download all images of stanford_cars from https://ai.stanford.edu/~jkrause/cars/car_dataset.html
.
The download file is as: car_ims/000001.jpg, 000002.jpg, ..., 016185.jpg
It seems that the provided StanforCar_prepare_csv.py does not handle on this file?
Is there any other preprocess on the downloaded car_ims
? Thanks!
您好!看了您的论文有一个地方不太明白。您在文中说“For each descriptor xi, we find its k-nearest neighbors”。有441个local descriptors,在5way 5shot5的情况下,假设现在计算support set中与query image第n个descriptor最近的k个descriptors,请问是只在support set的5个对应的第n个descriptor找k个最近邻的还是在所有5*441 descriptor上找k个最近邻。另外实验设置,我看您在table1中写的k=3,shot为1的时候k也是3吗?
谢谢您
thanks for your detailed code. I am not sure about the settings of DN4-IoI2 in paper 4.6. As the paper said,
DN4-IoI-2 restricts the search for the k-NN of a query’s local descriptor within each individual support image
in 5way5shot, if i understand right, lol-2 select top k local descriptors from one image pool instead from one class pool (as DN4 settings) for a query local descriptor, so there are 5 times(5 shot) local descriptors selected, then sum 5 times similarities for one query local descriptor. If I miss sth, please help me figure it out.
hello,
sorry for asking you here as i did not find the email in your paper. I have a question about an important experiment. Do you compare your network with the baseline that compute cosine distance after global pooling (as is done in prototypical network). That can be seen as to use 1 vector vs 1 vector to compute distance, and meanwhile yours is many vectors vs many vectors.
I think the greatest novelty in your work is to use local features instead of global feature after pooling. However, a baseline model that remains all the parts the same except the global pooling added is missing. Did you have such comparison experiments?
There is a paper published on ICLR 2019 https://arxiv.org/pdf/1904.04232.pdf. In this paper, they also evaluate the performance of protonet on the CUB dataset and their result is far better than the result reported in this paper. So I am wondering how the result is obtained in this paper?
In your code I see that you fix the parameters of Batch Normalization after 1 epoch (10000 episodes), but when I remove the constraint (i.e., before training use model.train(), and before val/test use model.eval()), the performance will drop sharply.
Have you observed the same degradation w/o fixing the BN params? and why is that?
Very nice job!!! I tried to use resnet as a backbone just like what you did in my own experiment. However, it didn't improve performance as we expected and even performed worse than 4-conv. I wonder if there are some tricks when you train your model with a resnet. Thank you very much.
作者,您好。最近想在您的基础上,发表一篇小样本的论文,您方便提供一下可视化部分的代码吗?
In a previous issue concerning BN parameter freezing after first epoch in the old DN4 version (#12) you mentioned it is done in order to prevent performance degradation which I assume is caused by overfitting to the training set distributions. However, in the new version you don't do it anymore. Curiously enough after removing the BN parameter freezing I even obtained a slight increase in accuracy R@1. Could you explain what is happening? I was always skeptical about the approach in your code to freeze after the 1st epoch, since this means we basically treat the rest of the training as fine-tuning - but this doesn't make sense, since we randomly shuffle the dataset in each epoch and randomly construct the mini-batches, plus we don't use a different split for finetuning. Thank you @WenbinLee
Additional notes:
Before, when freezing the BN parameters after the first epoch, I was using kaiming init:
def init_weights_kaiming(m):
if isinstance(m, nn.Conv2d) or isinstance(m, nn.Linear):
nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='leaky_relu')
if m.bias is not None:
nn.init.constant_(m.bias, 0)
When switching to normal init, the performance wouldn't improve after the first epoch (after freezing the BN parameters) and after a 2 epochs it would start degrading. When BN freezing was removed, the training was working well.
Thanks your work, I am very interested in the idea about the DN4.
I have trained the model. How do I load a single image and test?
Hi,
Thank you very much to share your code with us!
I try to reproduce your results in your paper, and rerun you code directly. But I found the results always a bit lower than that reported in your paper. Should some hyperparameters be tuned?
Also,I found the learning rate decayed 0.05 each interval. Should it be changed to 0.5, or 0.05 is OK?
Hope to hear from you~
I tried to train with multi GPU but I got error "expected batch size 34 target batch size 75" when I used 2 GPU?
Does anyone here have a code for doing inference but only for one image? I really appreciate it if you can share the idea and code.
Thanks
您好,请问对于CUB数据集,epoch和miniImagenet一样还是30吗?因为感觉CUB数据集减少了。学习率衰减仍是10个epoch减一半吗?我对于参数调整不太敏感,希望收到作者的回复
作者您好,我最近在研究小样本图像分类算法,看到您的这篇论文我感到非常值得学习,但是代码下载下来发现有报错,不知道是什么原因?代码如下:
if self.maml:
self.C1 = Conv2d_fw(indim, bottleneckdim, kernel_size=1, bias=False)
self.BN1 = BatchNorm2d_fw(bottleneckdim)
self.C2 = Conv2d_fw(bottleneckdim, bottleneckdim, kernel_size=3, stride=2 if half_res else 1,padding=1)
self.BN2 = BatchNorm2d_fw(bottleneckdim)
self.C3 = Conv2d_fw(bottleneckdim, outdim, kernel_size=1, bias=False)
以上代码中,Conv2d_fw、BatchNorm2d_fw都出现了报错,没找到这个是在哪里定义的?恳求作者帮忙指点一下,非常感谢!
Hi. I'm really interested in your work, and I notice that the "os.listdir(images_dir)" is not sorted,
DN4/dataset/CubBird_prepare_csv.py
Line 32 in cb605fd
你好,请问这个代码只支持batch_size=1吗?我看了和运行了DN4_Train_5way5shot.py文件,发现把batch_size设为2时,会把2个episode的support set、query set糅合在一起,就是episode1中的support set 的 class 0 和 episode2 中的support set 的class 0的样本会当成是同一个class 0,相当于class 0变成了10 shot,但这10个样本实际来自2个不同的类。
Hello, this is a great work and thank you for open the resource.
I realized that a lot of few-shot learning network has a pre-training stage and maybe fine-tuning during the classification. But I have not found any code regarding to the pre-training, so does the DN4 need a pre-training or it is just train from scratch based on the data with a few labeled samples?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.