LemurPwned / video-sampler

Effective frame sampling for ML applications.
https://lemurpwned.github.io/video-sampler/
MIT License
16 stars 5 forks source link

make torch, transformers, pysrt and spacy optional dependencies #30

Closed fcakyon closed 3 weeks ago

fcakyon commented 3 weeks ago

fixes https://github.com/LemurPwned/video-sampler/issues/29 cc: @LemurPwned

Summary by Sourcery

Make torch, transformers, pysrt and spacy optional dependencies by moving their imports inside the functions that require them, reducing the need for these packages unless their specific functionality is used.

Enhancements:

sourcery-ai[bot] commented 3 weeks ago

Reviewer's Guide by Sourcery

This pull request makes torch, transformers, and spacy optional dependencies by modifying import statements and type annotations. The changes aim to improve the package's flexibility and reduce unnecessary dependencies for users who don't need specific features.

Updated class diagram for KeywordExtractor and feature model

classDiagram
    class KeywordExtractor {
        +list~str~ keywords
        +spacy.Language nlp
        +set~str~ lemmatized_keywords
        +__init__(keywords: list~str~)
    }

    class FeatureModel {
        +AutoFeatureExtractor extractor
        +ResNetModel model
        +build_feature_model(model_str: str)
    }

    KeywordExtractor --> spacy: uses
    FeatureModel --> transformers: uses

File-Level Changes

Change Details Files
Modified type annotation for torch.Tensor
  • Changed 'torch.Tensor' to 'torch.Tensor' (with quotes) in method signature
video_sampler/gating.py
Made spacy an optional import
  • Added import statement for spacy inside the KeywordExtractor class init method
video_sampler/language/keyword_capture.py
Made transformers an optional import
  • Moved import statement for AutoFeatureExtractor and ResNetModel inside the build_feature_model function
video_sampler/visualisation/clustering.py

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).
LemurPwned commented 3 weeks ago

Thanks a lot @fcakyon. I'll use this PR to bump the version and add missing base requirements as well

LemurPwned commented 3 weeks ago

@sourcery-ai review

sourcery-ai[bot] commented 3 weeks ago

Hi @LemurPwned! 👋

Only authors and team members can run @sourcery-ai commands on public repos.

LemurPwned commented 3 weeks ago

Thanks again @fcakyon for your contribution!

fcakyon commented 3 weeks ago

@LemurPwned thanks for your fast response 🙏🏻