Skip to content

fix(reidmodel): torch.squeeze removes batch dim for batch (+3 more) - #88

Open
andrewwhitecdw wants to merge 1 commit into
NVlabs:masterfrom
andrewwhitecdw:bugfix/reidmodel-assorted-c5bff2e2
Open

fix(reidmodel): torch.squeeze removes batch dim for batch (+3 more)#88
andrewwhitecdw wants to merge 1 commit into
NVlabs:masterfrom
andrewwhitecdw:bugfix/reidmodel-assorted-c5bff2e2

Conversation

@andrewwhitecdw

@andrewwhitecdw andrewwhitecdw commented Jul 27, 2026

Copy link
Copy Markdown

Small fixes in reIDmodel.py:

fix: torch.squeeze removes batch dim for batch size 1

Fix: Replace:

    def forward(self, x):
        x = self.model.features(x)
        x = torch.squeeze(x)
        x = self.classifier(x)
        return x

with:

    def forward(self, x):
        x = self.model.features(x)
        x = x.view(x.size(0), -1)
        x = self.classifier(x)
        return x

fix: torch.squeeze removes batch dim when batch size is 1

Fix: Replace:

        x = torch.cat((x0,x1),1)
        x = torch.squeeze(x)
        x = self.classifier(x)
        return x

with:

        x = torch.cat((x0,x1),1)
        x = x.view(x.size(0), -1)
        x = self.classifier(x)
        return x

fix: PCB part classifier passes bool as dropout rate

Fix: Replace:

            setattr(self, name, ClassBlock(2048, class_num, True, False, 256))

with:

            setattr(self, name, ClassBlock(2048, class_num, droprate=0.5, relu=False, num_bottleneck=256))

fix: ft_net_dense fails on batch size 1 due to torch.squeeze

Fix: Replace:

        x = self.model.features(x)
        x = torch.squeeze(x)
        x = self.classifier(x)

with:

        x = self.model.features(x)
        x = x.view(x.size(0), -1)
        x = self.classifier(x)

Files changed

  • reIDmodel.py

Reconstructed from original sweep finding patch(es).
@andrewwhitecdw
andrewwhitecdw force-pushed the bugfix/reidmodel-assorted-c5bff2e2 branch from a24ce84 to 39ebc20 Compare August 2, 2026 19:26
@andrewwhitecdw
andrewwhitecdw marked this pull request as ready for review August 3, 2026 22:06
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

Successfully merging this pull request may close these issues.

1 participant