Respect CLI parameters (#179)

the CLI parameters ckpt and config now work if required - the paths were hardcoded.
This commit is contained in:
AbdBarho 2022-08-28 12:50:54 +01:00 committed by GitHub
parent 33890563d2
commit ee571eaced
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -301,7 +301,7 @@ def try_loading_RealESRGAN(model_name: str):
try_loading_RealESRGAN('RealESRGAN_x4plus') try_loading_RealESRGAN('RealESRGAN_x4plus')
if opt.optimized: if opt.optimized:
sd = load_sd_from_config("models/ldm/stable-diffusion-v1/model.ckpt") sd = load_sd_from_config(opt.ckpt)
li, lo = [], [] li, lo = [], []
for key, v_ in sd.items(): for key, v_ in sd.items():
sp = key.split('.') sp = key.split('.')
@ -337,8 +337,8 @@ if opt.optimized:
model = model if opt.no_half else model.half() model = model if opt.no_half else model.half()
modelCS = modelCS if opt.no_half else modelCS.half() modelCS = modelCS if opt.no_half else modelCS.half()
else: else:
config = OmegaConf.load("configs/stable-diffusion/v1-inference.yaml") config = OmegaConf.load(opt.config)
model = load_model_from_config(config, "models/ldm/stable-diffusion-v1/model.ckpt") model = load_model_from_config(config, opt.ckpt)
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu") device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
model = (model if opt.no_half else model.half()).to(device) model = (model if opt.no_half else model.half()).to(device)