Skip to content

Commit 05eb772

Browse files
authored
Merge pull request #1 from zhiqwang/fcos-empty-test
Add unittest for empty instance training
2 parents 1451d97 + 4b2a856 commit 05eb772

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/test_models_detection_negative_samples.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,17 @@ def test_forward_negative_sample_retinanet(self):
143143

144144
assert_equal(loss_dict["bbox_regression"], torch.tensor(0.0))
145145

146+
def test_forward_negative_sample_fcos(self):
147+
model = torchvision.models.detection.fcos_resnet50_fpn(
148+
num_classes=2, min_size=100, max_size=100, pretrained_backbone=False
149+
)
150+
151+
images, targets = self._make_empty_sample()
152+
loss_dict = model(images, targets)
153+
154+
assert_equal(loss_dict["bbox_regression"], torch.tensor(0.0))
155+
assert_equal(loss_dict["bbox_ctrness"], torch.tensor(0.0))
156+
146157
def test_forward_negative_sample_ssd(self):
147158
model = torchvision.models.detection.ssd300_vgg16(num_classes=2, pretrained_backbone=False)
148159

0 commit comments

Comments
 (0)