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

Update visual prompting task (finetuning & zero-shot learning) #2892

Merged
merged 30 commits into from
Feb 23, 2024

Conversation

sungchul2
Copy link
Contributor

@sungchul2 sungchul2 commented Feb 6, 2024

Summary

This PR includes:

  • Update data & model pipeline to support multiple prompt types
  • Internalize preprocessing pipeline into learn and infer for standalone module usecase
  • Update how to get reference features (saved in the model -> get as input)
    • Save reference info in the specific location to load it for infer
  • Bug fixes

How to test

$ tox -vv -e unittest-all-py310-pt2 -- tests/unit/algorithms/visual_prompting
======================================================= 257 passed, 128 warnings in 60.99s (0:01:00) =======================================================
Name                                                                                                                   Stmts   Miss  Cover   Missing
----------------------------------------------------------------------------------------------------------------------------------------------------
src/otx/algorithms/visual_prompting/adapters/openvino/model_wrappers/openvino_models.py                                   94      3    97%   53, 88, 160    
src/otx/algorithms/visual_prompting/adapters/pytorch_lightning/callbacks/inference.py                                     54      0   100%                  
src/otx/algorithms/visual_prompting/adapters/pytorch_lightning/config/visual_prompting_config.py                          43      2    95%   108-109        
src/otx/algorithms/visual_prompting/adapters/pytorch_lightning/datasets/dataset.py                                       147     18    88%   106, 168, 171, 212, 216, 228-236, 262, 325-331, 401-404
src/otx/algorithms/visual_prompting/adapters/pytorch_lightning/datasets/pipelines/sam_transforms.py                       42      0   100%
src/otx/algorithms/visual_prompting/adapters/pytorch_lightning/datasets/pipelines/transforms.py                           38      1    97%   59
src/otx/algorithms/visual_prompting/adapters/pytorch_lightning/models/backbones/tiny_vit.py                              333      4    99%   223, 395, 509, 685
src/otx/algorithms/visual_prompting/adapters/pytorch_lightning/models/backbones/vit.py                                   122      0   100%
src/otx/algorithms/visual_prompting/adapters/pytorch_lightning/models/decoders/sam_mask_decoder.py                       153      1    99%   194
src/otx/algorithms/visual_prompting/adapters/pytorch_lightning/models/encoders/sam_image_encoder.py                       10      1    90%   30
src/otx/algorithms/visual_prompting/adapters/pytorch_lightning/models/encoders/sam_prompt_encoder.py                      94      0   100%
src/otx/algorithms/visual_prompting/adapters/pytorch_lightning/models/utils/layer_norm.py                                 14      0   100%
src/otx/algorithms/visual_prompting/adapters/pytorch_lightning/models/utils/mlp_block.py                                  10      0   100%
src/otx/algorithms/visual_prompting/adapters/pytorch_lightning/models/visual_prompters/segment_anything.py               228      7    97%   219, 229-233, $46-548
src/otx/algorithms/visual_prompting/adapters/pytorch_lightning/models/visual_prompters/zero_shot_segment_anything.py     344     65    81%   59-75, 185-186$ 209-213, 322, 324-328, 330-331, 333-334, 341-342, 401, 403, 432-434, 436, 471, 519, 527, 556, 560-561, 587, 589-595, 668, 724, 728-731, 735, 739-743, 747-$62
src/otx/algorithms/visual_prompting/configs/base/configuration.py                                                         40      0   100%
src/otx/algorithms/visual_prompting/configs/base/configuration_enums.py                                                    4      0   100%
src/otx/algorithms/visual_prompting/configs/sam_tiny_vit/configuration.py                                                  4      4     0%   7-13
src/otx/algorithms/visual_prompting/configs/sam_tiny_vit/ptq_optimization_config.py                                        5      5     0%   2-22
src/otx/algorithms/visual_prompting/configs/sam_vit_b/configuration.py                                                     4      4     0%   7-13
src/otx/algorithms/visual_prompting/configs/sam_vit_b/ptq_optimization_config.py                                           5      0   100%
src/otx/algorithms/visual_prompting/configs/zero_shot_sam_tiny_vit/configuration.py                                        4      4     0%   7-13
src/otx/algorithms/visual_prompting/configs/zero_shot_sam_tiny_vit/ptq_optimization_config.py                              5      5     0%   2-22           
src/otx/algorithms/visual_prompting/tasks/inference.py                                                                   326     28    91%   103, 188, 231-232, 237, 353, 363, 368, 395, 417-418, 447, 451-460, 467-468, 472-473, 569, 579, 584, 612, 679                                                               
src/otx/algorithms/visual_prompting/tasks/openvino.py                                                                    550     65    88%   163, 312, 347-348, 356, 404, 410-412, 414, 436, 506, 537, 568, 601, 655, 848, 852-854, 881-882, 886-887, 927, 993, 996, 1016, 1030, 1056, 1065-1067, 1093-1145
src/otx/algorithms/visual_prompting/tasks/train.py                                                                        41      4    90%   90-91, 98-99
src/otx/algorithms/visual_prompting/utils/visual_prompting_utils.py                                                        3      3     0%   17-22

$ tox -vv -e tests-all-py310-pt2 -- tests/integration/cli/visual_prompting
================================================== 23 passed, 4 skipped, 6 warnings in 253.63s (0:04:13) ===================================================

$ tox -vv -e tests-all-py310-pt2 -- tests/e2e/cli/visual_prompting
======================================================== 29 passed, 6 warnings in 470.07s (0:07:50) ========================================================

Checklist

  • I have added unit tests to cover my changes.​
  • I have added integration tests to cover my changes.​
  • I have added e2e tests for validation.
  • I have added the description of my changes into CHANGELOG in my target branch (e.g., CHANGELOG in develop).​
  • I have updated the documentation in my target branch accordingly (e.g., documentation in develop).
  • I have linked related issues.

License

  • I submit my code changes under the same Apache License that covers the project.
    Feel free to contact the maintainers if that's a concern.
  • I have updated the license header for each file (see an example below).
# Copyright (C) 2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

@sungchul2 sungchul2 added this to the 1.6.0 milestone Feb 6, 2024
@github-actions github-actions bot added ALGO Any changes in OTX Algo Tasks implementation TEST Any changes in tests labels Feb 6, 2024
@sungchul2 sungchul2 marked this pull request as ready for review February 19, 2024 11:46
@sungchul2 sungchul2 requested a review from a team as a code owner February 19, 2024 11:46
@sungchul2 sungchul2 requested a review from wonjuleee February 19, 2024 11:46
@sungchul2 sungchul2 enabled auto-merge (squash) February 19, 2024 11:46
Copy link

codecov bot commented Feb 20, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 64 lines in your changes are missing coverage. Please review.

Project coverage is 81.16%. Comparing base (610987b) to head (826408f).

Files Patch % Lines
...els/visual_prompters/zero_shot_segment_anything.py 80.19% 40 Missing ⚠️
.../otx/algorithms/visual_prompting/tasks/openvino.py 93.61% 12 Missing ⚠️
...ing/adapters/pytorch_lightning/datasets/dataset.py 77.14% 8 Missing ⚠️
...htning/models/visual_prompters/segment_anything.py 91.89% 3 Missing ⚠️
...dapters/openvino/model_wrappers/openvino_models.py 96.15% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2892      +/-   ##
===========================================
+ Coverage    81.06%   81.16%   +0.09%     
===========================================
  Files          520      520              
  Lines        39361    39535     +174     
===========================================
+ Hits         31909    32088     +179     
+ Misses        7452     7447       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

wonjuleee
wonjuleee previously approved these changes Feb 22, 2024
Copy link
Contributor

@wonjuleee wonjuleee left a comment

Choose a reason for hiding this comment

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

In general, it looks good to me, but I left few minor comments.

@sungchul2 sungchul2 dismissed stale reviews from wonjuleee and jaegukhyun via a01345a February 22, 2024 06:11
wonjuleee
wonjuleee previously approved these changes Feb 22, 2024
Copy link
Contributor

@wonjuleee wonjuleee left a comment

Choose a reason for hiding this comment

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

LGTM

jaegukhyun
jaegukhyun previously approved these changes Feb 22, 2024
MarkByun
MarkByun previously approved these changes Feb 22, 2024
Copy link

@MarkByun MarkByun left a comment

Choose a reason for hiding this comment

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

LGTM

@sungchul2 sungchul2 dismissed stale reviews from MarkByun, jaegukhyun, and wonjuleee via d030427 February 22, 2024 06:56
@sungchul2 sungchul2 merged commit ac993c8 into openvinotoolkit:develop Feb 23, 2024
17 checks passed
@sungchul2 sungchul2 deleted the update_vpm branch February 23, 2024 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ALGO Any changes in OTX Algo Tasks implementation TEST Any changes in tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants