Skip to content

Commit

Permalink
🐞Fix ollama (#2519)
Browse files Browse the repository at this point in the history
Fix ollama

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
  • Loading branch information
ashwinvaidya17 authored Jan 20, 2025
1 parent 9357f9c commit 088882f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ core = [
"open-clip-torch>=2.23.0,<2.26.1",
]
openvino = ["openvino>=2024.0", "nncf>=2.10.0", "onnx>=1.16.0"]
vlm = ["ollama<0.4.0", "openai", "python-dotenv","transformers"]
vlm = ["ollama>=0.4.0", "openai", "python-dotenv","transformers"]
loggers = [
"comet-ml>=3.31.7",
"gradio>=4",
Expand Down
7 changes: 3 additions & 4 deletions src/anomalib/models/image/vlm_ad/backends/ollama.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
from .base import Backend

if module_available("ollama"):
from ollama import chat
from ollama._client import _encode_image
from ollama import Image, chat
else:
chat = None

Expand Down Expand Up @@ -101,7 +100,7 @@ def add_reference_images(self, image: str | Path) -> None:
Args:
image (str | Path): Path to the reference image file
"""
self._ref_images_encoded.append(_encode_image(image))
self._ref_images_encoded.append(Image(value=image))

@property
def num_reference_images(self) -> int:
Expand Down Expand Up @@ -144,7 +143,7 @@ def predict(self, image: str | Path, prompt: Prompt) -> str:
if not chat:
msg = "Ollama is not installed. Please install it using `pip install ollama`."
raise ImportError(msg)
image_encoded = _encode_image(image)
image_encoded = Image(value=image)
messages = []

# few-shot
Expand Down

0 comments on commit 088882f

Please sign in to comment.