question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting error while feeding custom dataset

See original GitHub issue

I want to train the reidentification model on VeRi vehicle dataset. I followed the instructions given here on how to use custom dataset: https://kaiyangzhou.github.io/deep-person-reid/user_guide.html#use-your-own-dataset

When I try to train “hacnn” model on this custom (VeRi) dataset, I am not able to train the model. Please find below the dataset statistics and the error that I am getting:

=> Loading train (source) dataset
=> Loaded VeRiDataset
  ----------------------------------------
  subset   | # ids | # images | # cameras
  ----------------------------------------
  train    |   575 |    37746 |        20
  query    |   200 |     1678 |        19
  gallery  |   200 |    11579 |        19
  ----------------------------------------
=> Loading test (target) dataset
=> Loaded VeRiDataset
  ----------------------------------------
  subset   | # ids | # images | # cameras
  ----------------------------------------
  train    |   575 |    37746 |        20
  query    |   200 |     1678 |        19
  gallery  |   200 |    11579 |        19
  ----------------------------------------


  **************** Summary ****************
  train            : ['veri_dataset']
  # train datasets : 1
  # train ids      : 575
  # train images   : 37746
  # train cameras  : 20
  test             : ['veri_dataset']
  *****************************************


=> Start training
/home/rajat/MyPC/DFKI/MasterThesis/Vehicle_Reidentification/veri/lib/python3.6/site-packages/torch/nn/functional.py:2457: UserWarning: nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.
  warnings.warn("nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.")
Traceback (most recent call last):
  File "train_torchreid.py", line 52, in <module>
    print_freq=10
  File "/home/rajat/MyPC/DFKI/MasterThesis/Vehicle_Reidentification/veri/lib/python3.6/site-packages/torchreid-0.7.8-py3.6-linux-x86_64.egg/torchreid/engine/engine.py", line 100, in run
    self.train(epoch, max_epoch, trainloader, fixbase_epoch, open_layers, print_freq)
  File "/home/rajat/MyPC/DFKI/MasterThesis/Vehicle_Reidentification/veri/lib/python3.6/site-packages/torchreid-0.7.8-py3.6-linux-x86_64.egg/torchreid/engine/image/softmax.py", line 99, in train
    loss = self._compute_loss(self.criterion, outputs, pids)
  File "/home/rajat/MyPC/DFKI/MasterThesis/Vehicle_Reidentification/veri/lib/python3.6/site-packages/torchreid-0.7.8-py3.6-linux-x86_64.egg/torchreid/engine/engine.py", line 302, in _compute_loss
    loss = DeepSupervision(criterion, outputs, targets)
  File "/home/rajat/MyPC/DFKI/MasterThesis/Vehicle_Reidentification/veri/lib/python3.6/site-packages/torchreid-0.7.8-py3.6-linux-x86_64.egg/torchreid/losses/__init__.py", line 21, in DeepSupervision
    loss += criterion(x, y)
  File "/home/rajat/MyPC/DFKI/MasterThesis/Vehicle_Reidentification/veri/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/rajat/MyPC/DFKI/MasterThesis/Vehicle_Reidentification/veri/lib/python3.6/site-packages/torchreid-0.7.8-py3.6-linux-x86_64.egg/torchreid/losses/cross_entropy_loss.py", line 47, in forward
    targets = torch.zeros(log_probs.size()).scatter_(1, targets.unsqueeze(1).data.cpu(), 1)
RuntimeError: Invalid index in scatter at /pytorch/aten/src/TH/generic/THTensorEvenMoreMath.cpp:551

Note: The same code is working fine if I use “market1501” dataset instead of my custom one.

Please help me in solving this issue.

Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
KaiyangZhoucommented, Jun 17, 2019

you need to relabel the training images so that the label starts from 0 and increments by 1 (think about how the classification layer is constructed and how a one-hot vector is generated given a label) e.g. raw_label=>new_label 1=>0 3=>1 4=>2 7=>3 8=>4

there is one simple way to convert the label

label_dict = {label: index for index, label in enumerate(labelset)}
new_label = label_dict[raw_label]
0reactions
youngjae-avikuscommented, Dec 19, 2022

@Rajat-Mehta

Could you tell me your custom_datset code?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is my custom dataset giving attribute error? - Stack Overflow
Images is a 2d list of Pillow images and string labels and the createimages function works outside of the class. I am not...
Read more >
How to get rid of custom tool errors on dataset designer save ...
I upgraded to VS 2015 from VS 2013 and now anytime I try to make changes to datasets via the dataset designer, I...
Read more >
Fix upload errors with feeds in business data - Google Ads Help
Fix upload errors with feeds in business data. If your data set or feed isn't formatted right, this can prevent your ads from...
Read more >
Step-by-step instructions for training YOLOv7 on a Custom ...
Follow this guide to get step-by-step instructions for running YOLOv7 model training within a Gradient Notebook on a custom dataset.
Read more >
Solved: Re: Dataset status - check error - Dataiku Community
So you can use "Python check" instead of numeric check for checking the column value ranges. In Python check, you can write your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found