Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Costum dataset num_class issue and debug #8

Open
FORSOLADU opened this issue Aug 5, 2024 · 0 comments
Open

Costum dataset num_class issue and debug #8

FORSOLADU opened this issue Aug 5, 2024 · 0 comments

Comments

@FORSOLADU
Copy link

I found that if I use my own data set and change the class number to 7, an error will be reported:

UserWarning: Using a target size (torch.Size([4, 7, 64, 64])) that is different to the input size (torch.Size([4, 6, 64, 64])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size
...
RuntimeError: The size of tensor a (6) must match the size of tensor b (7) at non-singleton dimension 1.

This is because the MCC output code writes the shape as a fixed value 6. The following is the debug report,

  1. models/CC.py
    L14:
    def __init__(self, net_name, gpu_id): -> def __init__(self, net_name, gpu_id, num_class):

L25:

self.CCN = ccnet() ->
if self.net_name == 'MCC':  # +
   self.CCN=ccnet(num_class=num_class)  # +
else:  # + 
    self.CCN = ccnet() 
  1. models/counters/MCC.py
    L160: self.output_layer = SCAModule(self.project_out, 6) -> self.output_layer = SCAModule(self.project_out, num_class)
  2. trainer.py
    L36: self.net = CrowdCounter(self.net_name, self.gpu_id) -> self.net = CrowdCounter(self.net_name, self.gpu_id, self.num_classes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant