From ead706535479c349fccdb4e7fe258cfb047e7e6f Mon Sep 17 00:00:00 2001
From: "Chandrashekar V.T" <57014454+chandrashekarvt@users.noreply.github.com>
Date: Fri, 5 Apr 2024 00:51:15 +0530
Subject: [PATCH] Added support to load clip model from local file path
 (#12577)

---
 .../llama_index/embeddings/clip/base.py                       | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/llama-index-integrations/embeddings/llama-index-embeddings-clip/llama_index/embeddings/clip/base.py b/llama-index-integrations/embeddings/llama-index-embeddings-clip/llama_index/embeddings/clip/base.py
index e00840128..9e13b5068 100644
--- a/llama-index-integrations/embeddings/llama-index-embeddings-clip/llama_index/embeddings/clip/base.py
+++ b/llama-index-integrations/embeddings/llama-index-embeddings-clip/llama_index/embeddings/clip/base.py
@@ -7,6 +7,7 @@ from llama_index.core.constants import DEFAULT_EMBED_BATCH_SIZE
 from llama_index.core.embeddings.multi_modal_base import MultiModalEmbedding
 from llama_index.core.schema import ImageType
 from PIL import Image
+import os
 
 logger = logging.getLogger(__name__)
 
@@ -86,7 +87,8 @@ class ClipEmbedding(MultiModalEmbedding):
 
         try:
             self._device = "cuda" if torch.cuda.is_available() else "cpu"
-            if self.model_name not in AVAILABLE_CLIP_MODELS:
+            is_local_path = os.path.exists(self.model_name)
+            if not is_local_path and self.model_name not in AVAILABLE_CLIP_MODELS:
                 raise ValueError(
                     f"Model name {self.model_name} is not available in CLIP."
                 )
-- 
GitLab