Giter Club home page Giter Club logo

distributionbalancedloss's People

Contributors

hqqasw avatar liuziwei7 avatar wutong16 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

distributionbalancedloss's Issues

Support multi-GPU training?

Hi,
I tried to run
python tools/train.py configs/coco/LT_resnet50_pfc_DB.py --gpus 2

and met some bugs:

File "/data2/cjq/DistributionBalancedLoss/mllt/models/losses/resample_loss.py", line 164, in rebalance_weight
repeat_rate = torch.sum( gt_labels.float() * self.freq_inv, dim=1, keepdim=True)
RuntimeError: expected device cuda:1 and dtype Float but got device cuda:0 and dtype Float

Does this code support multi-GPU training? Have you ever tried, or I should fix these bugs by myself?

Thanks for you code !

Dataset?

Is the dataset first released by authors? where can I download the dataset you evaluated in your manuscript? Or is there any widely-accepted public dataset for multi-label long-tailed classification task?

problem of train set and experiment

thanks for your detailed code!

  1. according to your paper and codes, train set only contains 1909 images for coco datasets followed by pareto distribution with max=1200 min=1. i am confused about the params settings, the train set is too samll, why not try to set a larger max param to construct a larger train set.
  2. in table 1, for the ERM settings, are all images sampled uniformly without class aware sampler ? just as most common simply baseline(just like training imagenet except for BCEloss)? I have done some experiments on original coco14 datasets(also a long-tailed distribution), but i find using class-aware sampler get a inferior performance than baseline, 2~3 point below. maybe there is something wrong in my implementation.

About code implementation of eq7

Hey thanks for the code 😄 but have some questions!!

if 'neg_scale' in self.logit_reg:
logits = logits * (1 - labels) * self.neg_scale + logits * labels
weight = weight / self.neg_scale * (1 - labels) + weight * labels

Isn't this inconsistent with eq7
Screenshot 2022-10-28 at 2 25 03 AM

  1. Like line 159 is dealing with the exp power in eq7 right? (Line 159) why are we directly multiplying it with labels, that anyhow occurs when we pass it to self.cls_criterion right? (same goes for weight)

  2. Bit confused in name

    cls_score, weight = self.logit_reg_functions(label.float(), cls_score, weight)

    Is cls_score here (logits passed through sigmoid/softmax) or just pure raw classifier outputs?,
    because even though we call it cls_score it's passed the to the same F.binary_cross_entropy_with_logits_loss

Question regarding the model

this model trains images. Can it be used to train numerical training data to do a multi-label classification problem?

ModuleNotFoundError: No module named 'lvis'

Traceback (most recent call last):
File "tools/train.py", line 11, in
from mllt.datasets import build_dataset
File "/content/drive/My Drive/DistributionBalancedLoss/mllt/datasets/init.py", line 4, in
from .Lvis import LvisDataset
File "/content/drive/My Drive/DistributionBalancedLoss/mllt/datasets/Lvis.py", line 2, in
from lvis.lvis import LVIS
ModuleNotFoundError: No module named 'lvis'
when I run python tools/train.py configs/coco/LT_resnet50_pfc_DB.py , this erorr is rasied. I think a lvis file should be existed, however, i can't find it. can you tell how to solve this erorr? thank you!

FileNotFoundError: [Errno 2] No such file or directory: '/mnt/SSD/det/coco/annotations/instances_train2017.json'

Traceback (most recent call last):
File "tools/train.py", line 108, in
main()
File "tools/train.py", line 85, in main
train_dataset = build_dataset(cfg.data.train)
File "/root/autodl-tmp/DB_loss/DistributionBalancedLoss/mllt/datasets/builder.py", line 36, in build_dataset
dataset = build_from_cfg(cfg, DATASETS)
File "/root/autodl-tmp/DB_loss/DistributionBalancedLoss/mllt/utils/registry.py", line 74, in build_from_cfg
return obj_type(**args)
File "/root/autodl-tmp/DB_loss/DistributionBalancedLoss/mllt/datasets/coco.py", line 27, in init
super(CocoDataset, self).init(**kwargs)
File "/root/autodl-tmp/DB_loss/DistributionBalancedLoss/mllt/datasets/custom.py", line 59, in init
self.img_infos = self.load_annotations(ann_file, LT_ann_file)
File "/root/autodl-tmp/DB_loss/DistributionBalancedLoss/mllt/datasets/coco.py", line 32, in load_annotations
self.coco = COCO(ann_file)
File "/root/miniconda3/envs/blast/lib/python3.7/site-packages/pycocotools-2.0-py3.7-linux-x86_64.egg/pycocotools/coco.py", line 84, in init
dataset = json.load(open(annotation_file, 'r'))
FileNotFoundError: [Errno 2] No such file or directory: '/mnt/SSD/det/coco/annotations/instances_train2017.json'

When I run python tools/train.py configs/coco/LT_resnet50_pfc_DB.py ,this error was rasied. I think this is because the program did not find the location of coco dataset. But I'm not sure. Can you tell me how to solve this error? Thank you!

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [64, 109]], which is output 0 of SigmoidBackward0, is at version 1; expected version 0 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [64, 109]], which is output 0 of SigmoidBackward0, is at version 1; expected version 0 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!

i am getting the above error while calling the loss.backward() line

Lower mAP when training on VOC

Hi, thank you for providing your source code of the paper,
Actually, I run you training code of VOC dataset for 3 times, but always get the Total mAP at around 77.7mAP. I notice in your paper "Table 1", the mAP of your "DB-focal" is 78.94. I was wondering if I did something wrong and why this is the case ?

Below is the log-out information of your training code.
Split: head mAP:0.7344 acc:0.8429 micro:0.6096 macro:0.5392
Split:middle mAP:0.8359 acc:0.9375 micro:0.6400 macro:0.6527
Split: tail mAP:0.7651 acc:0.9400 micro:0.5492 macro:0.5305
Split: Total mAP:0.7771 acc:0.9101 micro:0.6024 macro:0.5698

Thanks in advance.

formulation error in Eq 7

in Eq7, the for positive samples, zik in exponent should be -zik,and for negative samples,-λ *zik should be λ *zik, which is consistent with formulation in Eq5.

please correct me if there is something wrong. thanks~

How to use the ResampleLoss?

I tried to introduce the ResampleLoss function into my code and found that it did not work properly.

  1. My training code uses the classic training method:
pred = model(img).sigmoid()
loss = config.loss_func(pred, label)
optimizer.zero_grad()
loss.backward()           #There is a problem here!!!
optimizer.step()
  1. I have changed the code to reduction = 'mean'.

  2. Now there are the following problems that cannot be solved:

Traceback (most recent call last):
  File "/home/xxx/run.py", line 5, in <module>
    train()
  File "/home/xxx/train.py", line 73, in train
    loss.backward()
  File "/home/xxx/miniconda3/envs/test/lib/python3.8/site-packages/torch/_tensor.py", line 307, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
  File "/home/xxx/miniconda3/envs/test/lib/python3.8/site-packages/torch/autograd/__init__.py", line 154, in backward
    Variable._execution_engine.run_backward(
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [32, 15]], which is output 0 of SigmoidBackward0, is at version 1; expected version 0 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!

I hope I can get your help on how to use this loss function.
Thanks!

Reproduction of Distribution-Balanced Loss on VOC Dataset

Distribution-Balanced Loss is a very good work, we reproduced the experimental results in coco long tail experiment, but the difference of mAP on VOC dataset is almost 1 point, is there something wrong with our settings, looking forward to your reply~
feab3d95c0ad8b8c89e46613266a741

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.