wutong16 / distributionbalancedloss Goto Github PK
View Code? Open in Web Editor NEW[ ECCV 2020 Spotlight ] Pytorch implementation for "Distribution-Balanced Loss for Multi-Label Classification in Long-Tailed Datasets"
[ ECCV 2020 Spotlight ] Pytorch implementation for "Distribution-Balanced Loss for Multi-Label Classification in Long-Tailed Datasets"
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 !
How could i reproduce the results "R-BCE" on the VOC dataset? I use Res50 + GAP + fc and only get 74 mAP.
--
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?
thanks for your detailed code!
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.Hey thanks for the code 😄 but have some questions!!
DistributionBalancedLoss/mllt/models/losses/resample_loss.py
Lines 158 to 160 in 14460d0
Isn't this inconsistent with eq7
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)
Bit confused in name
cls_score
here (logits passed through sigmoid/softmax) or just pure raw classifier outputs?,cls_score
it's passed the to the same F.binary_cross_entropy_with_logits_loss
this model trains images. Can it be used to train numerical training data to do a multi-label classification problem?
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!
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!
i am getting the above error while calling the loss.backward() line
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.
如题,谢谢~
Hi, how can I use DistributionBalancedLoss on my own dataset?
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~
ResampleLoss
function into my code and found that it did not work properly.pred = model(img).sigmoid()
loss = config.loss_func(pred, label)
optimizer.zero_grad()
loss.backward() #There is a problem here!!!
optimizer.step()
I have changed the code to reduction = 'mean'
.
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!
args.gpus is missing
DistributionBalancedLoss/tools/train.py
Line 59 in a3ecaa9
maybe add parser.add_argument('--gpus', default=1) in the parse_args()
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.