Verg-Avesta / CounTR

CounTR: Transformer-based Generalised Visual Counting
https://verg-avesta.github.io/CounTR_Webpage/
MIT License
89 stars 7 forks source link

Train on New Dataset #42

Open LokeSiewWen opened 3 months ago

LokeSiewWen commented 3 months ago

Hi, may I know how to train on new Dataset? I am facing this error when trying to input the new dataset.

Traceback (most recent call last): File "/content/CounTR/FSC_finetune_cross.py", line 456, in main(args) File "/content/CounTR/FSC_finetune_cross.py", line 287, in main output = model(samples, boxes, shot_num) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1520, in _call_impl return forward_call(*args, *kwargs) File "/content/CounTR/models_mae_cross.py", line 206, in forward pred = self.forward_decoder(latent, boxes, shot_num) # [N, 384, 384] File "/content/CounTR/models_mae_cross.py", line 174, in forward_decoder y = torch.cat(y1,dim=0).reshape(shot_num,N,C).to(x.device) RuntimeError: shape '[2, 1, 512]' is invalid for input of size 512 Traceback (most recent call last): File "/content/CounTR/FSC_finetune_cross.py", line 456, in main(args) File "/content/CounTR/FSC_finetune_cross.py", line 287, in main output = model(samples, boxes, shot_num) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl return self._call_impl(args, kwargs) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1520, in _call_impl return forward_call(*args, **kwargs) File "/content/CounTR/models_mae_cross.py", line 206, in forward pred = self.forward_decoder(latent, boxes, shot_num) # [N, 384, 384] File "/content/CounTR/models_mae_cross.py", line 174, in forward_decoder y = torch.cat(y1,dim=0).reshape(shot_num,N,C).to(x.device) RuntimeError: shape '[2, 1, 512]' is invalid for input of size 512 [08:42:33.922301] [08:42:33.922375] [08:42:33.922399] [08:42:33.922411] [08:42:33.922425] [08:42:33.922438] [08:42:33.922451] [08:42:33.922477]

Thanks for your help in advance!

Verg-Avesta commented 3 months ago

This seems to be a shape mismatch problem. So if you can ensure that the form and size of the new input dataset are the same as FSC147, there should be no problem.

LokeSiewWen commented 3 months ago

Hi, Thanks! Is working now. But I do have a few questions and would like some clarifications from you.

  1. Do we need to manually generate the density map?
  2. Are they necessary during training?

image

Thanks for your help in advance! :)

Verg-Avesta commented 3 months ago

Yes, I believe it is essential to manually generate density maps, as Gaussian density maps could lead to smaller errors compared to dot annotations.

famersalltheday commented 2 months ago

Hi, Thanks! Is working now. But I do have a few questions and would like some clarifications from you.

  1. Do we need to manually generate the density map?
  2. Are they necessary during training?

image

Thanks for your help in advance! :)

Hi, I was wondering about the process for training new data sets. Is a new dataset file created, or is it a supplement to the original FSC147 file? Because I found out that the annotation.json in FSC147 is read-only, I can't edit it.