Skip to content

Commit 144dc3d

Browse files
committed
Add unit tests and PR description with issue link
1 parent 337eb05 commit 144dc3d

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# PR Description
2+
3+
# Description
4+
5+
Implementation of the **FCOS (Fully Convolutional One-Stage Object Detection)** model as a new project in the TensorFlow Model Garden.
6+
7+
This PR addresses issue #10275: **[Help wanted] FCOS: Fully Convolutional One-Stage Object Detection**.
8+
9+
This works corresponds to the request to implement the [FCOS](https://arxiv.org/abs/1904.01355) paper. The implementation provides an anchor-free object detection framework with the following components:
10+
* **Backbone**: ResNet50 (configurable via standard TF Model Garden mechanisms).
11+
* **FPN**: Feature Pyramid Network for multi-scale feature extraction.
12+
* **Heads**: Shared heads for Classification, Box Regression, and Centerness.
13+
* **Losses**: IOULoss, FocalCrossEntropy, and BinaryCrossEntropy for centerness.
14+
15+
## Type of change
16+
17+
- [x] A new research paper code implementation
18+
- [x] New feature (non-breaking change which adds functionality)
19+
20+
## Tests
21+
22+
I have performed local testing to verify the integrity of the model architecture and the training loop.
23+
24+
* **Unit Tests**: Added `official/projects/fcos/model/model_test.py` to verify model instantiation and forward pass shapes.
25+
* **Integration Test**: Ran `main.py` (training loop) locally with a subset of COCO data to verify the pipeline from data loading to gradient updates.
26+
27+
**Test Configuration**:
28+
* **Hardware**: Intel i7-1260P, NVIDIA RTX 3050 (Laptop environment)
29+
* **OS**: Linux
30+
* **TensorFlow Version**: 2.x
31+
32+
## Checklist
33+
34+
- [x] I have signed the [Contributor License Agreement](https://github.com/tensorflow/models/wiki/Contributor-License-Agreements). [User Action Required]
35+
- [x] I have read [guidelines for pull request](https://github.com/tensorflow/models/wiki/Submitting-a-pull-request).
36+
- [x] My code follows the [coding guidelines](https://github.com/tensorflow/models/wiki/Coding-guidelines).
37+
- [x] I have performed a self [code review](https://github.com/tensorflow/models/wiki/Code-review) of my own code.
38+
- [x] I have commented my code, particularly in hard-to-understand areas.
39+
- [x] I have made corresponding changes to the documentation (Added `README.md`).
40+
- [x] My changes generate no new warnings.
41+
- [x] I have added tests that prove my fix is effective or that my feature works.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
import tensorflow as tf
3+
from absl.testing import parameterized
4+
from official.projects.fcos.model.model import FCOS
5+
6+
class FCOSModelTest(parameterized.TestCase, tf.test.TestCase):
7+
8+
def test_fcos_model_instantiation_and_forward_pass(self):
9+
"""Tests that the FCOS model can be instantiated and run."""
10+
11+
# Create the model
12+
model = FCOS()
13+
14+
# specific input shape [Batch, H, W, 3]
15+
input_image_size = (1, 800, 1024, 3)
16+
inputs = tf.random.normal(input_image_size)
17+
18+
# Run forward pass
19+
outputs = model(inputs, training=False)
20+
21+
# Check output keys
22+
self.assertIn('classifier', outputs)
23+
self.assertIn('box', outputs)
24+
self.assertIn('centerness', outputs)
25+
26+
# Check output shapes (approximate checks based on feature map sizes)
27+
# We expect a flattened output of shape [Batch, N_points, Channels]
28+
self.assertEqual(outputs['classifier'].shape[0], 1)
29+
self.assertEqual(outputs['box'].shape[0], 1)
30+
self.assertEqual(outputs['centerness'].shape[0], 1)
31+
32+
# Detailed shape check for channels
33+
self.assertEqual(outputs['classifier'].shape[-1], 80) # 80 classes
34+
self.assertEqual(outputs['box'].shape[-1], 4) # 4 regression coords
35+
self.assertEqual(outputs['centerness'].shape[-1], 1)# 1 centerness score
36+
37+
if __name__ == '__main__':
38+
tf.test.main()

0 commit comments

Comments
 (0)