From 4aec58130674959512b8c73dc350d3435cf78177 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Mon, 20 Nov 2023 22:40:00 -0800 Subject: [PATCH] Handle image search setup related warning Ideally should rename model_directory to config_directory or some such but the current image search code will need to be migrated soon. So changing the variable name and creating a migration script for old khoj.yml files using model-directory variable isn't worth it Remove the explicity set of number of threads to use by pytorch. Use the default used by it. --- src/khoj/search_type/image_search.py | 4 ---- src/khoj/utils/rawconfig.py | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/khoj/search_type/image_search.py b/src/khoj/search_type/image_search.py index 8c0a3cdb..fd5107ad 100644 --- a/src/khoj/search_type/image_search.py +++ b/src/khoj/search_type/image_search.py @@ -12,7 +12,6 @@ from sentence_transformers import SentenceTransformer, util from PIL import Image from tqdm import trange import torch -from khoj.utils import state # Internal Packages from khoj.utils.helpers import get_absolute_path, get_from_dict, resolve_absolute_path, load_model, timer @@ -26,9 +25,6 @@ logger = logging.getLogger(__name__) def initialize_model(search_config: ImageSearchConfig): - # Initialize Model - torch.set_num_threads(4) - # Convert model directory to absolute path search_config.model_directory = resolve_absolute_path(search_config.model_directory) diff --git a/src/khoj/utils/rawconfig.py b/src/khoj/utils/rawconfig.py index 4c97aedd..d36a36ff 100644 --- a/src/khoj/utils/rawconfig.py +++ b/src/khoj/utils/rawconfig.py @@ -72,6 +72,9 @@ class ImageSearchConfig(ConfigBase): encoder_type: Optional[str] = None model_directory: Optional[Path] = None + class Config: + protected_namespaces = () + class SearchConfig(ConfigBase): image: Optional[ImageSearchConfig] = None