@@ -70,10 +70,10 @@ def postscript():
70
70
Command-line version:
71
71
python scripts/invoke.py
72
72
73
- Remember to activate that 'invokeai' environment before running invoke.py.
74
-
75
- Or, if you used one of the automated installers , execute "invoke.sh" (Linux/Mac)
76
- or "invoke.bat" (Windows) to start the script .
73
+ If you installed manually, remember to activate the 'invokeai'
74
+ environment before running invoke.py. If you installed using the
75
+ automated installation script , execute "invoke.sh" (Linux/Mac) or
76
+ "invoke.bat" (Windows) to start InvokeAI .
77
77
78
78
Have fun!
79
79
'''
@@ -243,10 +243,10 @@ def download_weight_datasets(models:dict, access_token:str):
243
243
for mod in models .keys ():
244
244
repo_id = Datasets [mod ]['repo_id' ]
245
245
filename = Datasets [mod ]['file' ]
246
- print ( os .path .join (Globals .root ,Model_dir ,Weights_dir ), file = sys . stderr )
246
+ dest = os .path .join (Globals .root ,Model_dir ,Weights_dir )
247
247
success = hf_download_with_resume (
248
248
repo_id = repo_id ,
249
- model_dir = os . path . join ( Globals . root , Model_dir , Weights_dir ) ,
249
+ model_dir = dest ,
250
250
model_name = filename ,
251
251
access_token = access_token
252
252
)
@@ -494,12 +494,12 @@ def download_clipseg():
494
494
495
495
#-------------------------------------
496
496
def download_safety_checker ():
497
- print ('Installing safety model for NSFW content detection...' ,file = sys .stderr )
497
+ print ('Installing model for NSFW content detection...' ,file = sys .stderr )
498
498
try :
499
499
from diffusers .pipelines .stable_diffusion .safety_checker import StableDiffusionSafetyChecker
500
500
from transformers import AutoFeatureExtractor
501
501
except ModuleNotFoundError :
502
- print ('Error installing safety checker model:' )
502
+ print ('Error installing NSFW checker model:' )
503
503
print (traceback .format_exc ())
504
504
return
505
505
safety_model_id = "CompVis/stable-diffusion-safety-checker"
@@ -520,6 +520,7 @@ def download_weights(opt:dict):
520
520
return
521
521
else :
522
522
print ('** Cannot download models because no Hugging Face access token could be found. Please re-run without --yes' )
523
+ return
523
524
else :
524
525
choice = user_wants_to_download_weights ()
525
526
@@ -584,7 +585,7 @@ def select_outputs(root:str,yes_to_all:bool=False):
584
585
585
586
#-------------------------------------
586
587
def initialize_rootdir (root :str ,yes_to_all :bool = False ):
587
- assert os .path .exists ('./configs' ),'Run this script from within the top level of the InvokeAI source code directory, "InvokeAI"'
588
+ assert os .path .exists ('./configs' ),'Run this script from within the InvokeAI source code directory, "InvokeAI" or the runtime directory "invokeai". '
588
589
589
590
print (f'** INITIALIZING INVOKEAI RUNTIME DIRECTORY **' )
590
591
root_selected = False
@@ -603,19 +604,50 @@ def initialize_rootdir(root:str,yes_to_all:bool=False):
603
604
print (f'\n You may change the chosen directories at any time by editing the --root and --outdir options in "{ Globals .initfile } ",' )
604
605
print (f'You may also change the runtime directory by setting the environment variable INVOKEAI_ROOT.\n ' )
605
606
607
+ enable_safety_checker = True
608
+ default_sampler = 'k_heun'
609
+ default_steps = '20' # deliberately a string - see test below
610
+
611
+ sampler_choices = ['ddim' ,'k_dpm_2_a' ,'k_dpm_2' ,'k_euler_a' ,'k_euler' ,'k_heun' ,'k_lms' ,'plms' ]
612
+
613
+ if not yes_to_all :
614
+ print ('The NSFW (not safe for work) checker blurs out images that potentially contain sexual imagery.' )
615
+ print ('It can be selectively enabled at run time with --nsfw_checker, and disabled with --no-nsfw_checker.' )
616
+ print ('The following option will set whether the checker is enabled by default. Like other options, you can' )
617
+ print (f'change this setting later by editing the file { Globals .initfile } .' )
618
+ enable_safety_checker = yes_or_no ('Enable the NSFW checker by default?' ,enable_safety_checker )
619
+
620
+ print ('\n The next choice selects the sampler to use by default. Samplers have different speed/performance' )
621
+ print ('tradeoffs. If you are not sure what to select, accept the default.' )
622
+ sampler = None
623
+ while sampler not in sampler_choices :
624
+ sampler = input (f'Default sampler to use? ({ ", " .join (sampler_choices )} ) [{ default_sampler } ]:' ) or default_sampler
625
+
626
+ print ('\n The number of denoising steps affects both the speed and quality of the images generated.' )
627
+ print ('Higher steps often (but not always) increases the quality of the image, but increases image' )
628
+ print ('generation time. This can be changed at run time. Accept the default if you are unsure.' )
629
+ steps = ''
630
+ while not steps .isnumeric ():
631
+ steps = input (f'Default number of steps to use during generation? [{ default_steps } ]:' ) or default_steps
632
+ else :
633
+ sampler = default_sampler
634
+ steps = default_steps
635
+
636
+ safety_checker = '--nsfw_checker' if enable_safety_checker else '--no-nsfw_checker'
637
+
606
638
for name in ('models' ,'configs' ,'embeddings' ):
607
639
os .makedirs (os .path .join (root ,name ), exist_ok = True )
608
640
for src in (['configs' ]):
609
641
dest = os .path .join (root ,src )
610
642
if not os .path .samefile (src ,dest ):
611
643
shutil .copytree (src ,dest ,dirs_exist_ok = True )
612
- os .makedirs (outputs , exist_ok = True )
644
+ os .makedirs (outputs , exist_ok = True )
613
645
614
646
init_file = os .path .expanduser (Globals .initfile )
615
- if not os . path . exists ( init_file ):
616
- print (f'Creating the initialization file at "{ init_file } ".\n ' )
617
- with open (init_file ,'w' ) as f :
618
- f .write (f'''# InvokeAI initialization file
647
+
648
+ print (f'Creating the initialization file at "{ init_file } ".\n ' )
649
+ with open (init_file ,'w' ) as f :
650
+ f .write (f'''# InvokeAI initialization file
619
651
# This is the InvokeAI initialization file, which contains command-line default values.
620
652
# Feel free to edit. If anything goes wrong, you can re-initialize this file by deleting
621
653
# or renaming it and then running configure_invokeai.py again.
@@ -626,23 +658,18 @@ def initialize_rootdir(root:str,yes_to_all:bool=False):
626
658
# the --outdir option controls the default location of image files.
627
659
--outdir="{ outputs } "
628
660
661
+ # generation arguments
662
+ { safety_checker }
663
+ --sampler={ sampler }
664
+ --steps={ steps }
665
+
629
666
# You may place other frequently-used startup commands here, one or more per line.
630
667
# Examples:
631
668
# --web --host=0.0.0.0
632
669
# --steps=20
633
670
# -Ak_euler_a -C10.0
634
671
#
635
- '''
636
- )
637
- else :
638
- print (f'Updating the initialization file at "{ init_file } ".\n ' )
639
- with open (init_file ,'r' ) as infile , open (f'{ init_file } .tmp' ,'w' ) as outfile :
640
- for line in infile .readlines ():
641
- if not line .startswith ('--root' ) and not line .startswith ('--outdir' ):
642
- outfile .write (line )
643
- outfile .write (f'--root="{ root } "\n ' )
644
- outfile .write (f'--outdir="{ outputs } "\n ' )
645
- os .replace (f'{ init_file } .tmp' ,init_file )
672
+ ''' )
646
673
647
674
#-------------------------------------
648
675
class ProgressBar ():
0 commit comments