Skip to content

Commit d587586

Browse files
committed
Added "--clip-models-path" switch to avoid using default "~/.cache/clip" and enable to run under unprivileged user without homedir
1 parent 17a2076 commit d587586

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

modules/interrogate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ def load_clip_model(self):
5656
import clip
5757

5858
if self.running_on_cpu:
59-
model, preprocess = clip.load(clip_model_name, device="cpu")
59+
model, preprocess = clip.load(clip_model_name, device="cpu", download_root=shared.cmd_opts.clip_models_path)
6060
else:
61-
model, preprocess = clip.load(clip_model_name)
61+
model, preprocess = clip.load(clip_model_name, download_root=shared.cmd_opts.clip_models_path)
6262

6363
model.eval()
6464
model = model.to(devices.device_interrogate)

modules/shared.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
parser.add_argument("--scunet-models-path", type=str, help="Path to directory with ScuNET model file(s).", default=os.path.join(models_path, 'ScuNET'))
5252
parser.add_argument("--swinir-models-path", type=str, help="Path to directory with SwinIR model file(s).", default=os.path.join(models_path, 'SwinIR'))
5353
parser.add_argument("--ldsr-models-path", type=str, help="Path to directory with LDSR model file(s).", default=os.path.join(models_path, 'LDSR'))
54+
parser.add_argument("--clip-models-path", type=str, help="Path to directory with CLIP model file(s).", default=None)
5455
parser.add_argument("--xformers", action='store_true', help="enable xformers for cross attention layers")
5556
parser.add_argument("--force-enable-xformers", action='store_true', help="enable xformers for cross attention layers regardless of whether the checking code thinks you can run it; do not make bug reports if this fails to work")
5657
parser.add_argument("--deepdanbooru", action='store_true', help="enable deepdanbooru interrogator")

0 commit comments

Comments
 (0)