DaiShiResearch / TransNeXt

[CVPR 2024] Code release for TransNeXt model
Apache License 2.0
387 stars 15 forks source link

Test the TransNext model #20

Closed JuergenZhang closed 2 months ago

JuergenZhang commented 2 months ago

Hello,

I am interested in testing the TransNeXt framework but am facing some constraints due to company privacy settings which prevent me from downloading public datasets. To work around this, I'd like to use an initialized tensor to test the input and output of the model directly. Here is the code snippet I am using: input_tensor = torch.rand(8, 3, 224, 224) model = TransNeXt() output = model(input_tensor) However, I encounter the following error: RuntimeError: The size of tensor a (196) must match the size of tensor b (3136) at non-singleton dimension 2

From what I understand, 196 comes from segmenting the 224x224 input image, and 3136 arises from the get_seqlen_and_mask function. If I intend to use the TransNeXt class by itself, what should be the correct input shape? I believe it should be the typical shape coming out of a dataloader: [batch_size, channel, height, width].

Could you please clarify or provide guidance on how to correctly format the input for testing the model with a tensor?

Thank you for your assistance.