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

Hugging face model #2

Open
wants to merge 5 commits into
base: llm-pipeline
Choose a base branch
from
Open

Hugging face model #2

wants to merge 5 commits into from

Conversation

Bepitic
Copy link
Owner

@Bepitic Bepitic commented Aug 12, 2024

πŸ“ Description

  • Add Hugging Face Wrapper for LLava-interleave models.
  • HF llava

✨ Changes

Select what type of change your PR is:

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • πŸ”¨ Refactor (non-breaking change which refactors the code base)
  • πŸš€ New feature (non-breaking change which adds functionality)
  • πŸ’₯ Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • πŸ“š Documentation update
  • πŸ”’ Security update

βœ… Checklist

Before you submit your pull request, please make sure you have completed the following steps:

  • πŸ“‹ I have summarized my changes in the CHANGELOG and followed the guidelines for my type of change (skip for minor changes, documentation updates, and test enhancements).
  • πŸ“š I have made the necessary updates to the documentation (if applicable).
  • πŸ§ͺ I have written tests that support my changes and prove that my fix is effective or my feature works (if applicable).

For more information about code review checklists, see the Code Review Checklist.

Signed-off-by: Bepitic <[email protected]>
Signed-off-by: Bepitic <[email protected]>
Signed-off-by: Bepitic <[email protected]>
Copy link

@samet-akcay samet-akcay left a comment

Choose a reason for hiding this comment

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

Thanks for adding this support. I've added few comments.

src/anomalib/models/image/hugging_face_wrapper/__init__.py Outdated Show resolved Hide resolved
self.max_new_tokens = max_new_tokens
self.pre_images: list[str] = []

self.model = LlavaForConditionalGeneration.from_pretrained(

Choose a reason for hiding this comment

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

Does this mean that models would only be Llava-based ?


@staticmethod
def configure_optimizers() -> None:
"""WinCLIP doesn't require optimization, therefore returns no optimizers."""

Choose a reason for hiding this comment

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

WinCLIP?

return

def validation_step(self, batch: dict[str, str | torch.Tensor], *args, **kwargs) -> dict:
"""Validation Step of WinCLIP."""

Choose a reason for hiding this comment

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

Same here, Huggingface or Llava?

Returns:
ref_images (Tensor): A tensor containing the reference images.
"""
ref_images: list[str] = []

Choose a reason for hiding this comment

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

Just for the consistency with the name of the method

Suggested change
ref_images: list[str] = []
reference_images: list[str] = []

def _load_image(self, image_file: str) -> Image.Image:
return Image.open(image_file).convert("RGB")

def _api_call_zero_shot(self, image_path: str) -> str:

Choose a reason for hiding this comment

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

Would it be possible for a user to configure the prompt if needed? Or does it have to be hardcoded?

__all__ = ["HuggingFaceWrapper"]


class HuggingFaceWrapper(AnomalyModule):

Choose a reason for hiding this comment

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

Is this a Wrapper or a Model?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants