Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add FCOS #4961

Merged
merged 94 commits into from
Jan 21, 2022
Merged

add FCOS #4961

merged 94 commits into from
Jan 21, 2022

Conversation

xiaohu2015
Copy link
Contributor

@xiaohu2015 xiaohu2015 commented Nov 18, 2021

The pr is about #2707
We (@xiaohu2015 and @zhiqwang ) implemented torchvision-style FCOS by referencing to detectron2 and AdelaiDet repo.

if train with the retinanet training command:

torchrun --nproc_per_node=8 train.py\
    --dataset coco --model fcos_resnet50_fpn --epochs 26 \
    --lr-steps 16 22 --aspect-ratio-group-factor 3 --lr 0.01 --amp

you can get:

 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.390
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.585
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.415
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.221
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.419
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.511
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.325
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.526
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.562
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.359
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.603
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.717

the AP result is better to the paper (38.6).

if train with training command (1x, 12 epoch, the dafult setting in the FCOS paper):

torchrun --nproc_per_node=8 train.py\
    --dataset coco --model fcos_resnet50_fpn --epochs 12 \
    --lr-steps 8 11 --aspect-ratio-group-factor 3 --lr 0.01 --amp

you can get:

 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.385
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.583
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.411
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.225
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.424
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.490
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.325
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.533
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.572
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.384
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.619
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.709

the AP result is smilar to the paper (38.6).

cc @jdsgomes

@facebook-github-bot
Copy link

facebook-github-bot commented Nov 18, 2021

💊 CI failures summary and remediations

As of commit 6840a7d (more details on the Dr. CI page):



🕵️ 1 new failure recognized by patterns

The following CI failures do not appear to be due to upstream breakages:

See CircleCI build unittest_linux_gpu_py3.8 (1/1)

Step: "Run tests" (full log | diagnosis details | 🔁 rerun)

test/test_utils.py::test_draw_keypoints_errors �[33mSKIPPED�[0m (We're in a C...)�[31m [ 99%]�[0m
test/test_utils.py::test_draw_segmentation_masks[1-blue] �[33mSKIPPED�[0m (We...)�[31m [ 99%]�[0m

test/test_utils.py::test_draw_segmentation_masks[1-#FF00FF] �[33mSKIPPED�[0m�[31m      [ 99%]�[0m

test/test_utils.py::test_draw_segmentation_masks[1-colors3] �[33mSKIPPED�[0m�[31m      [ 99%]�[0m

test/test_utils.py::test_draw_segmentation_masks[1-colors4] �[33mSKIPPED�[0m�[31m      [ 99%]�[0m

test/test_utils.py::test_draw_segmentation_masks[1-colors5] �[33mSKIPPED�[0m�[31m      [ 99%]�[0m

test/test_utils.py::test_draw_segmentation_masks_errors �[33mSKIPPED�[0m (We'...)�[31m [ 99%]�[0m

test/test_utils.py::test_draw_keypoints_vanilla �[33mSKIPPED�[0m (We're in a ...)�[31m [ 99%]�[0m

test/test_utils.py::test_draw_keypoints_colored[red] �[33mSKIPPED�[0m (We're ...)�[31m [ 99%]�[0m

test/test_utils.py::test_draw_keypoints_colored[#FF00FF] �[33mSKIPPED�[0m (We...)�[31m [ 99%]�[0m

test/test_utils.py::test_draw_keypoints_colored[colors2] �[33mSKIPPED�[0m (We...)�[31m [ 99%]�[0m

test/test_utils.py::test_draw_keypoints_errors �[33mSKIPPED�[0m (We're in a C...)�[31m [ 99%]�[0m

test/test_video_gpu_decoder.py::TestVideoGPUDecoder::test_frame_reading �[33mSKIPPED�[0m�[31m [ 99%]�[0m

test/test_video_reader.py::TestVideoReader::test_stress_test_read_video_from_file �[33mSKIPPED�[0m�[31m [ 99%]�[0m

test/test_video_reader.py::TestVideoReader::test_read_video_from_file �[33mSKIPPED�[0m�[31m [ 99%]�[0m

test/test_video_reader.py::TestVideoReader::test_read_video_from_file_read_single_stream_only �[33mSKIPPED�[0m�[31m [ 99%]�[0m

test/test_video_reader.py::TestVideoReader::test_read_video_from_file_rescale_min_dimension �[33mSKIPPED�[0m�[31m [ 99%]�[0m

test/test_video_reader.py::TestVideoReader::test_read_video_from_file_rescale_max_dimension �[33mSKIPPED�[0m�[31m [ 99%]�[0m

test/test_video_reader.py::TestVideoReader::test_read_video_from_file_rescale_both_min_max_dimension �[33mSKIPPED�[0m�[31m [ 99%]�[0m

test/test_video_reader.py::TestVideoReader::test_read_video_from_file_rescale_width �[33mSKIPPED�[0m�[31m [ 99%]�[0m

test/test_video_reader.py::TestVideoReader::test_read_video_from_file_rescale_height �[33mSKIPPED�[0m�[31m [ 99%]�[0m

test/test_video_reader.py::TestVideoReader::test_read_video_from_file_rescale_width_and_height �[33mSKIPPED�[0m�[31m [ 99%]�[0m


🚧 1 ongoing upstream failure:

These were probably caused by upstream breakages that are not fixed yet.


This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@xiaohu2015 xiaohu2015 marked this pull request as draft November 18, 2021 13:15
torchvision/prototype/models/detection/fcos.py Outdated Show resolved Hide resolved
torchvision/models/detection/fcos.py Outdated Show resolved Hide resolved
torchvision/models/detection/fcos.py Show resolved Hide resolved
torchvision/models/detection/fcos.py Outdated Show resolved Hide resolved
torchvision/prototype/models/detection/fcos.py Outdated Show resolved Hide resolved
Copy link
Contributor

@jdsgomes jdsgomes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for all your patience and commitment. Looks great to me now and I think its ready to merge, but I will just wait for @datumbox approval to make sure I didn't miss any changes suggested by him.

torchvision/models/detection/fcos.py Outdated Show resolved Hide resolved
torchvision/prototype/models/detection/fcos.py Outdated Show resolved Hide resolved
Copy link
Contributor

@datumbox datumbox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks a lot @xiaohu2015 and @zhiqwang for your amazing work.

We are going to base our new model contribution process on this collaboration. @jdsgomes is currently leading this and we will ping you once this is drafted to get your input.

Looking forward working with you again, soon. Perhaps next target is EfficientNetV2? 😃

@jdsgomes jdsgomes merged commit 7d4bdd4 into pytorch:main Jan 21, 2022
@github-actions
Copy link

Hey @jdsgomes!

You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py

@jdsgomes
Copy link
Contributor

I have opened a ticket to add FCOS model in Pytorch Hub: pytorch/hub#265

facebook-github-bot pushed a commit that referenced this pull request Jan 26, 2022
Summary:
* add fcos

* update fcos

* add giou_loss

* add BoxLinearCoder for FCOS

* add full code for FCOS

* add giou loss

* add fcos

* add __all__

* Fixing lint

* Fixing lint in giou_loss.py

* Add typing annotation to fcos

* Add trained checkpoints

* Use partial to replace lambda

* Minor fixes to docstrings

* Apply ufmt format

* Fixing docstrings

* Fixing jit scripting

* Minor fixes to docstrings

* Fixing jit scripting

* Ignore mypy in fcos

* Fixing trained checkpoints

* Fixing unit-test of jit script

* Fixing docstrings

* Add test/expect/ModelTester.test_fcos_resnet50_fpn_expect.pkl

* Fixing test_detection_model_trainable_backbone_layers

* Update test_fcos_resnet50_fpn_expect.pkl

* rename stride to box size

* remove TODO and fix some typo

* merge some code for better

* impove the comments

* remove decode and encode of BoxLinearCoder

* remove some unnecessary hints

* use the default value in detectron2.

* update doc

* Add unittest for BoxLinearCoder

* Add types in FCOS

* Add docstring for BoxLinearCoder

* Minor fix for the docstring

* update doc

* Update fcos_resnet50_fpn_coco pretained weights url

* Update torchvision/models/detection/fcos.py

* Update torchvision/models/detection/fcos.py

* Update torchvision/models/detection/fcos.py

* Update torchvision/models/detection/fcos.py

* Add FCOS model documentation

* Fix typo in FCOS documentation

* Add fcos to the prototype builder

* Capitalize COCO_V1

* Fix params of fcos

* fix bug for partial

* Fixing docs indentation

* Fixing docs format in giou_loss

* Adopt Reference for GIoU Loss

* Rename giou_loss to generalized_box_iou_loss

* remove overwrite_eps

* Update AP test values

* Minor fixes for the docs

* Minor fixes for the docs

* Update torchvision/models/detection/fcos.py

* Update torchvision/prototype/models/detection/fcos.py

Reviewed By: jdsgomes, prabhat00155

Differential Revision: D33739385

fbshipit-source-id: 7dab616adfd0c34fe21f0153c1da51f97ef43b95

Co-authored-by: Vasilis Vryniotis <[email protected]>
Co-authored-by: Vasilis Vryniotis <[email protected]>
Co-authored-by: Vasilis Vryniotis <[email protected]>
Co-authored-by: Vasilis Vryniotis <[email protected]>
Co-authored-by: Zhiqiang Wang <[email protected]>
Co-authored-by: Zhiqiang Wang <[email protected]>
Co-authored-by: zhiqiang <[email protected]>
Co-authored-by: Joao Gomes <[email protected]>
Co-authored-by: Vasilis Vryniotis <[email protected]>
Co-authored-by: Joao Gomes <[email protected]>
@datumbox datumbox mentioned this pull request Feb 11, 2022
24 tasks
@datumbox datumbox mentioned this pull request Nov 7, 2022
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants