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

use n_threads param to call _embed_image_bytes fun #1834

Open
wants to merge 1 commit 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
6 changes: 3 additions & 3 deletions llama_cpp/llama_chat_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -2707,7 +2707,7 @@ def last_image_embed_free():
def load_image(self, image_url: str) -> bytes:
return self._load_image(image_url)

def _embed_image_bytes(self, image_bytes: bytes, n_threads_batch: int = 1):
def _embed_image_bytes(self, image_bytes: bytes, n_threads: int = 1):
if (
self._last_image_embed is not None
and self._last_image_hash is not None
Expand All @@ -2722,7 +2722,7 @@ def _embed_image_bytes(self, image_bytes: bytes, n_threads_batch: int = 1):
self._last_image_hash = None
embed = self._llava_cpp.llava_image_embed_make_with_bytes(
self.clip_ctx,
n_threads_batch,
n_threads,
(ctypes.c_uint8 * len(image_bytes)).from_buffer(
bytearray(image_bytes)
),
Expand Down Expand Up @@ -2813,7 +2813,7 @@ def __call__(
llama.eval(tokens)
else:
image_bytes = self.load_image(value)
embed = self._embed_image_bytes(image_bytes, llama.context_params.n_threads_batch)
embed = self._embed_image_bytes(image_bytes, llama.context_params.n_threads)
if llama.n_tokens + embed.contents.n_image_pos > llama.n_ctx():
raise ValueError(
f"Prompt exceeds n_ctx: {llama.n_tokens + embed.contents.n_image_pos} > {llama.n_ctx()}"
Expand Down