8000 refactor: Replace sam_embedding caching with lru_cache by wkentaro · Pull Request #1592 · wkentaro/labelme · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor: Replace sam_embedding caching with lru_cache #1592

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

Merged

Conversation

wkentaro
Copy link
Owner
@wkentaro wkentaro commented Jun 1, 2025

Why?

Less class attribute, the better.

@wkentaro wkentaro requested a review from Copilot June 1, 2025 04:30
@wkentaro wkentaro self-assigned this Jun 1, 2025
@wkentaro wkentaro changed the title Simplify sam_embedding caching by using functools.lru_cache refactor: Simplify sam_embedding caching by using functools.lru_cache Jun 1, 2025
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR simplifies the SAM embedding caching mechanism by replacing the custom OrderedDict with Python’s built-in functools.lru_cache.

  • Removed the instance-level caching variable and related logic.
  • Introduced _compute_image_embedding and __compute_image_embedding functions decorated with lru_cache.
  • Updated canvas-related methods to directly call the new caching functions.

@wkentaro wkentaro changed the title refactor: Simplify sam_embedding caching by using functools.lru_cache refactor: Replace sam_embedding caching with lru_cache Jun 1, 2025
@wkentaro wkentaro force-pushed the simplify_sam_embedding_caching_by_using_functools_lru_cache branch from f65eb32 to 4b271ee Compare June 1, 2025 04:31
@wkentaro wkentaro merged commit e1d7fc6 into main Jun 1, 2025
3 checks passed
@wkentaro wkentaro deleted the simplify_sam_embedding_caching_by_using_functools_lru_cache branch June 1, 2025 08:55
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.

1 participant
0