Skip to content

Implement dependency injection for BlipProcessor and BlipForConditionalGeneration in VideoDescriber initialization #2

Description

@chigwell

User Story
As a software developer,
I want dependency injection for BlipProcessor and BlipForConditionalGeneration in VideoDescriber initialization
so that I can mock these components during testing and easily swap models for flexibility.

Background
The current implementation directly initializes BlipProcessor and BlipForConditionalGeneration in VideoDescriber.__init__ (see frame_story/video_describer.py lines 13-14). This tight coupling:

  • Prevents proper mocking during unit tests (e.g., tests/test_video_describer.py relies on actual model loading)
  • Forces unnecessary model downloads during test runs
  • Limits customization of model versions/implementations
  • Creates longer test execution times due to real model initialization

Acceptance Criteria

  • Modify VideoDescriber.__init__ to accept optional processor and model parameters
  • Update get_video_descriptions to pass these dependencies through if provided
  • Refactor test_video_describer.py tests to use mocked processor/model
  • Ensure existing initialization works unchanged when no parameters are passed
  • Add type hints for new parameters in method signatures

Validation

  1. Verify VideoDescriber() initializes with default Salesforce/blip models when no args passed
  2. Confirm tests pass when using mocked processor/model in TestVideoDescriber.setUp()
  3. Check that custom models can be injected via VideoDescriber(processor=CustomProcessor(), model=CustomModel())
  4. Ensure describe_frames still generates valid descriptions after changes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions