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.
This commit is contained in:
Debanjum Singh Solanky 2023-11-20 22:40:00 -08:00
parent b06628ee31
commit 4aec581306
2 changed files with 3 additions and 4 deletions

View file

@ -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)

View file

@ -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