Skip to content

Commit

Permalink
fix: free last image embed in llava chat handler
Browse files Browse the repository at this point in the history
  • Loading branch information
abetlen committed May 9, 2024
1 parent 7712263 commit 3757328
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions llama_cpp/llama_chat_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -2615,6 +2615,11 @@ def embed_image_bytes(image_bytes: bytes):
if self._last_image_embed is not None and self._last_image_hash is not None and hash(image_bytes) == self._last_image_hash:
return self._last_image_embed
with suppress_stdout_stderr(disable=self.verbose):
# Free the previous image embed
if self._last_image_embed is not None:
self._llava_cpp.llava_image_embed_free(self._last_image_embed)
self._last_image_embed = None
self._last_image_hash = None
embed = (
self._llava_cpp.llava_image_embed_make_with_bytes(
self.clip_ctx,
Expand Down

0 comments on commit 3757328

Please sign in to comment.