This commit is contained in:
NielsRogge 2021-11-06 15:08:58 +01:00 committed by GitHub
parent 24b30d4d2f
commit 34307bb358
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -232,7 +232,9 @@ class BeitModelTest(ModelTesterMixin, unittest.TestCase):
# this can then be incorporated into _prepare_for_class in test_modeling_common.py # this can then be incorporated into _prepare_for_class in test_modeling_common.py
elif model_class.__name__ == "BeitForSemanticSegmentation": elif model_class.__name__ == "BeitForSemanticSegmentation":
batch_size, num_channels, height, width = inputs_dict["pixel_values"].shape batch_size, num_channels, height, width = inputs_dict["pixel_values"].shape
inputs_dict["labels"] = torch.zeros([self.model_tester.batch_size, height, width]).long() inputs_dict["labels"] = torch.zeros(
[self.model_tester.batch_size, height, width], device=torch_device
).long()
model = model_class(config) model = model_class(config)
model.to(torch_device) model.to(torch_device)
model.train() model.train()
@ -259,7 +261,9 @@ class BeitModelTest(ModelTesterMixin, unittest.TestCase):
# this can then be incorporated into _prepare_for_class in test_modeling_common.py # this can then be incorporated into _prepare_for_class in test_modeling_common.py
elif model_class.__name__ == "BeitForSemanticSegmentation": elif model_class.__name__ == "BeitForSemanticSegmentation":
batch_size, num_channels, height, width = inputs_dict["pixel_values"].shape batch_size, num_channels, height, width = inputs_dict["pixel_values"].shape
inputs_dict["labels"] = torch.zeros([self.model_tester.batch_size, height, width]).long() inputs_dict["labels"] = torch.zeros(
[self.model_tester.batch_size, height, width], device=torch_device
).long()
model = model_class(config) model = model_class(config)
model.to(torch_device) model.to(torch_device)
model.train() model.train()

View File

@ -318,7 +318,9 @@ class SegformerModelTest(ModelTesterMixin, unittest.TestCase):
# this can then be incorporated into _prepare_for_class in test_modeling_common.py # this can then be incorporated into _prepare_for_class in test_modeling_common.py
if model_class.__name__ == "SegformerForSemanticSegmentation": if model_class.__name__ == "SegformerForSemanticSegmentation":
batch_size, num_channels, height, width = inputs_dict["pixel_values"].shape batch_size, num_channels, height, width = inputs_dict["pixel_values"].shape
inputs_dict["labels"] = torch.zeros([self.model_tester.batch_size, height, width]).long() inputs_dict["labels"] = torch.zeros(
[self.model_tester.batch_size, height, width], device=torch_device
).long()
model = model_class(config) model = model_class(config)
model.to(torch_device) model.to(torch_device)
model.train() model.train()