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

🎨 Refactor ModelABC to Help Use Default Torch Models #867

Draft
wants to merge 6 commits into
base: dev-define-engines-abc
Choose a base branch
from

Conversation

shaneahmed
Copy link
Member

  • Refactor ModelABC to Help Use Default Torch Models
  • Remove infer_batch from ModelABC

@shaneahmed shaneahmed self-assigned this Sep 20, 2024
@shaneahmed shaneahmed added this to the Release v2.0.0 milestone Sep 20, 2024
@shaneahmed shaneahmed added the enhancement New feature or request label Sep 20, 2024
Signed-off-by: Shan E Ahmed Raza <[email protected]>
Copy link

codecov bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.43%. Comparing base (819e138) to head (e25a122).

Additional details and impacted files
@@                    Coverage Diff                     @@
##           dev-define-engines-abc     #867      +/-   ##
==========================================================
- Coverage                   91.52%   91.43%   -0.09%     
==========================================================
  Files                          71       71              
  Lines                        8920     8925       +5     
  Branches                     1184     1184              
==========================================================
- Hits                         8164     8161       -3     
- Misses                        742      750       +8     
  Partials                       14       14              

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


🚨 Try these New Features:

with torch.inference_mode():
output = model(img_patches_device)
# Output should be a single tensor or scalar
return {"probabilities": output.cpu().numpy()}
Copy link
Contributor

Choose a reason for hiding this comment

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

In the current develop branch, neither CNNModel, nor CNNBackbone returned dictionaries as output of their infer_batch() methods. Also, CNNModel currently returns an array, while CNNBackbone returns a list with the array. It might be fine, just wanted to highlight this.

CNNModel

return output.cpu().numpy()

CNNBackbone

return [output.cpu().numpy()]

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. We are aware of this. Our preference is to use torch nn models but to generalise for multi modal output we may need dictionaries. This PR is to check if we can move to generic torch models or we will need a sub class.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense.

…rch-nn-model

# Conflicts:
#	tests/models/test_arch_vanilla.py
#	tiatoolbox/models/architecture/vanilla.py
@shaneahmed shaneahmed marked this pull request as draft November 20, 2024 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants