move model path

feature/visualize-tokens
toshiaki1729 2024-05-08 04:39:03 +09:00
parent 6303fbe3b2
commit 4621d76286
3 changed files with 12 additions and 6 deletions

View File

@ -13,10 +13,10 @@ class BLIP2Captioning:
def load(self):
if self.model is None or self.processor is None:
self.processor = Blip2Processor.from_pretrained(
self.MODEL_REPO, cache_dir=paths.model_path / "aesthetic"
self.MODEL_REPO, cache_dir=paths.model_path
)
self.model = Blip2ForConditionalGeneration.from_pretrained(
self.MODEL_REPO, cache_dir=paths.model_path / "aesthetic"
self.MODEL_REPO, cache_dir=paths.model_path
).to(devices.device)
def unload(self):

View File

@ -1,6 +1,8 @@
from transformers import AutoProcessor, AutoModelForCausalLM
from modules import shared, devices, lowvram
from scripts.paths import paths
# brought from https://huggingface.co/docs/transformers/main/en/model_doc/git and modified
class GITLargeCaptioning:
@ -12,10 +14,12 @@ class GITLargeCaptioning:
def load(self):
if self.model is None or self.processor is None:
self.processor = AutoProcessor.from_pretrained(self.MODEL_REPO)
self.model = AutoModelForCausalLM.from_pretrained(self.MODEL_REPO).to(
shared.device
self.processor = AutoProcessor.from_pretrained(
self.MODEL_REPO, cache_dir=paths.model_path
)
self.model = AutoModelForCausalLM.from_pretrained(
self.MODEL_REPO, cache_dir=paths.model_path
).to(shared.device)
lowvram.send_everything_to_cpu()
def unload(self):

View File

@ -4,6 +4,8 @@ from typing import List, Tuple
from modules import shared, devices
import launch
from scripts.paths import paths
class WaifuDiffusionTagger:
# brought from https://huggingface.co/spaces/SmilingWolf/wd-v1-4-tags/blob/main/app.py and modified
@ -24,7 +26,7 @@ class WaifuDiffusionTagger:
if not self.model:
path_model = huggingface_hub.hf_hub_download(
self.MODEL_REPO, self.MODEL_FILENAME
self.MODEL_REPO, self.MODEL_FILENAME, cache_dir=paths.model_path
)
if (
"all" in shared.cmd_opts.use_cpu