add run-sd-local arg
This commit is contained in:
@@ -70,7 +70,7 @@ class SD(InpaintModel):
|
||||
def init_model(self, device: torch.device, **kwargs):
|
||||
from .sd_pipeline import StableDiffusionInpaintPipeline
|
||||
|
||||
model_kwargs = {}
|
||||
model_kwargs = {"local_files_only": kwargs['sd_run_local']}
|
||||
if kwargs['sd_disable_nsfw']:
|
||||
logger.info("Disable Stable Diffusion Model NSFW checker")
|
||||
model_kwargs.update(dict(
|
||||
|
||||
@@ -20,13 +20,18 @@ def parse_args():
|
||||
parser.add_argument(
|
||||
"--sd-disable-nsfw",
|
||||
action="store_true",
|
||||
help="Disable Stable Diffusion nsfw checker",
|
||||
help="Disable Stable Diffusion NSFW checker",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--sd-cpu-textencoder",
|
||||
action="store_true",
|
||||
help="Always run Stable Diffusion TextEncoder model on CPU",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--sd-run-local",
|
||||
action="store_true",
|
||||
help="After first time Stable Diffusion model downloaded, you can add this arg and remove --hf_access_token",
|
||||
)
|
||||
parser.add_argument("--device", default="cuda", type=str, choices=["cuda", "cpu"])
|
||||
parser.add_argument("--gui", action="store_true", help="Launch as desktop app")
|
||||
parser.add_argument(
|
||||
@@ -48,7 +53,7 @@ def parse_args():
|
||||
if imghdr.what(args.input) is None:
|
||||
parser.error(f"invalid --input: {args.input} is not a valid image file")
|
||||
|
||||
if args.model.startswith("sd"):
|
||||
if args.model.startswith("sd") and not args.sd_run_local:
|
||||
if not args.hf_access_token.startswith("hf_"):
|
||||
parser.error(
|
||||
f"sd(stable-diffusion) model requires huggingface access token. Check how to get token from: https://huggingface.co/docs/hub/security-tokens"
|
||||
|
||||
@@ -220,6 +220,7 @@ def main(args):
|
||||
hf_access_token=args.hf_access_token,
|
||||
sd_disable_nsfw=args.sd_disable_nsfw,
|
||||
sd_cpu_textencoder=args.sd_cpu_textencoder,
|
||||
sd_run_local=args.sd_run_local,
|
||||
callbacks=[diffuser_callback],
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user