Git Product home page Git Product logo

pca-net's Introduction

PCA-Net

Code for PCA-Net: Progressive Co-Attention Network for Fine-Grained Visual Classification arXiv

Requirement

python 3.6

PyTorch >= 1.1.1

torchvision >= 0.2.1

Training

Train from scratch with main.py.

Contact

Thanks for your attention! If you have any suggestion or question, you can leave a message here or contact us directly:

pca-net's People

Contributors

dongliangchang avatar tian1874 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

Watchers

 avatar  avatar  avatar

pca-net's Issues

datasets

请教一下,您是如何构造数据集的,train和test中的数据结构,非常希望能够得到您的答复!谢谢!

FileNotFoundError: [Errno 2] No such file or directory: './data/Birds/train/Myrtle_Warbler_0007_166897.jpg'

Namespace(batch_size=8, checkpoint_path='./checkpoint_bird', dataset='bird', decay_step=2, epochs=300, gamma=0.9, lr=0.001, model_name='resnet50', resume='', start_epoch=0) Start epoch 0, lr=0.001000 Traceback (most recent call last): File "F:/ganggang/retrieval/PCA-Net-main/main.py", line 135, in <module> train_acc, train_loss = train(train_loader, model, criterion, optimizer, center) File "F:\ganggang\retrieval\PCA-Net-main\train.py", line 14, in train for i, data in enumerate(train_loader): File "E:\ProgramData\Anaconda3\envs\ganggang\lib\site-packages\torch\utils\data\dataloader.py", line 346, in __next__ data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "E:\ProgramData\Anaconda3\envs\ganggang\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "E:\ProgramData\Anaconda3\envs\ganggang\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "F:\ganggang\retrieval\PCA-Net-main\dataset.py", line 65, in __getitem__ image = self.pil_loader(img_path) File "F:\ganggang\retrieval\PCA-Net-main\dataset.py", line 75, in pil_loader with open(imgpath, 'rb') as f: FileNotFoundError: [Errno 2] No such file or directory: './data/Birds/train/Myrtle_Warbler_0007_166897.jpg'
你好,我复现代码时,出现了这个错误,但是这个图片已经在我相应的文件夹中,请问如何解决?谢谢你

关于二分类

你好,这个网络使用2类数据分类,推理结果全是一样的类别,求指导

How to split the dataset?

I can't run the code easily, how to split the dataset for bird, car, and aircraft? How to get the corresponding train.txt and test.txt?
Looking forward to your reply!

Are centers updating the expected way?

Target_centers are normlized before calculating center offset.
target_centers = torch.nn.functional.normalize(target_centers, dim=-1) center_offset = (1-alpha)*(features.detach() - target_centers)
However, if features' norm is bigger than 1, these centers will move towards inf. While features' norm is smaller 1, these centers will head towards 0. So, you may let alone the normalization before calculating center offset.

显存占用问题

你好作者,我吧主干网络替换为resnet18,推理的时候显存占用为啥跟resnet50的时候一样呢

代码中有个公式不是很理解

def co_att(feature1, feature2):
B, N, W, H = feature1.shape
x1 = feature1.reshape(B, N, WH)
x2 = feature2.reshape(B, N, W
H)
I = -torch.bmm(x1, x2.permute(0,2,1))
I = F.softmax(I,2)
Y = torch.bmm(I, feature1.reshape(B, N, W*H)).reshape(B, N, W, H)
Y = Y + feature1
return Y
这段代码对应文中的哪些内容?

训练结果准确度无法提升问题请教?

训练了53个epoch,测试准确度还是只有0.39%,第1个epoch的时候准确度就是0.4多。说明真个训练网络都没有学习到。想问下我们这工程是论文官方的工程代码吗?是否能给出我们训练的结果?
训练数据使用bird,过程数据如下:

epoch train_acc train_loss
3 0.3504 5.3009
4 0.317 5.3007
51 0.367 5.2985
52 0.4171 5.2985

我觉得好奇的是我们网络为啥会丢掉一些卷积层的输出信息,位置如下Bottleneck:

   out = self.conv1(x)
    out = self.bn1(out)
    out = self.relu(out)
    out1 = out

    out = self.conv2(out)
    out = self.bn2(out)
    out = self.relu(out)

    if self.use_bp:
       #丢掉了out的32以后的所有通道,请问这样子构建的吗,为啥不直接self.conv2就构建32通道输出?
        out2 = out[:, :32, :, :]
        bilinear_features = self.bilinear_pooling(out1, out2)
        return out1, out2, bilinear_features

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.