Allow configuration of which SD model to use (#263)

* Allow configuration of which SD model to use

Closes https://github.com/lstein/stable-diffusion/issues/49 The syntax isn't quite the same (opting for --weights over --model), although --weights is more in-line with the existing naming convention.
This method also locks us into models in the models/ldm/stable-diffusion-v1/ directory. Personally, I'm not averse to this, although a secondary solution may be necessary if we wish to supply weights from an external directory.

* Fix typo

* Allow either filename OR filepath input for arg

This approach allows both
--weights SD13 
--weights C:/StableDiffusion/models/ldm/stable-diffusion-v1/SD13.ckpt
This commit is contained in:
David Wager 2022-08-31 19:20:28 +01:00 committed by GitHub
parent c52ba1b022
commit ed513397b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,7 +29,10 @@ def main():
width = 512
height = 512
config = 'configs/stable-diffusion/v1-inference.yaml'
weights = 'models/ldm/stable-diffusion-v1/model.ckpt'
if '.ckpt' in opt.weights:
weights = opt.weights
else:
weights = f'models/ldm/stable-diffusion-v1/{opt.weights}.ckpt'
print('* Initializing, be patient...\n')
sys.path.append('.')
@ -418,6 +421,11 @@ def create_argv_parser():
action='store_true',
help='Start in web server mode.',
)
parser.add_argument(
'--weights',
default='model',
help='Indicates the Stable Diffusion model to use.',
)
return parser