Skip to content

πŸ”’ fix(model): huggingface unsafe download #2823

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/anomalib/models/image/vlm_ad/backends/huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,15 @@ def processor(self) -> "ProcessorMixin":
if transformers is None:
msg = "transformers is not installed."
raise ValueError(msg)
self._processor = transformers.LlavaNextProcessor.from_pretrained(self.model_name)
loaded_processor = transformers.LlavaNextProcessor.from_pretrained(
self.model_name,
revision="main",
)
if isinstance(loaded_processor, tuple):
self._processor = loaded_processor[0]
else:
self._processor = loaded_processor
assert self._processor is not None
return self._processor

@property
Expand All @@ -128,7 +136,15 @@ def model(self) -> "PreTrainedModel":
if transformers is None:
msg = "transformers is not installed."
raise ValueError(msg)
self._model = transformers.LlavaNextForConditionalGeneration.from_pretrained(self.model_name)
loaded_model = transformers.LlavaNextForConditionalGeneration.from_pretrained(
self.model_name,
revision="main",
)
if isinstance(loaded_model, tuple):
self._model = loaded_model[0]
else:
self._model = loaded_model
assert self._model is not None
return self._model

@staticmethod
Expand Down
Loading