mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
add support for an initialization file, invokeai.init
- Place preferred startup command switches in a file named "invokeai.init". The file can consist of a single line of switches such as "--web --steps=28", a series of switches on each line, or any combination of the two. Example: ``` --web --host=0.0.0.0 --steps=28 --grid -f 0.6 -C 11.0 -A k_euler_a ``` - The following options, which were previously only available within the CLI, are now available on the command line as well: --steps --strength --cfg_scale --width --height --fit
This commit is contained in:
parent
2ad6ef355a
commit
1fe41146f0
3
.gitignore
vendored
3
.gitignore
vendored
@ -209,3 +209,6 @@ configs/models.yaml
|
|||||||
|
|
||||||
# weights (will be created by installer)
|
# weights (will be created by installer)
|
||||||
models/ldm/stable-diffusion-v1/*.ckpt
|
models/ldm/stable-diffusion-v1/*.ckpt
|
||||||
|
|
||||||
|
# ignore initfile
|
||||||
|
invokeai.init
|
||||||
|
@ -91,6 +91,10 @@ overridden on a per-prompt basis (see
|
|||||||
| `--port <port>` | | `9090` | Which port web server should listen for requests on. |
|
| `--port <port>` | | `9090` | Which port web server should listen for requests on. |
|
||||||
| `--config <path>` | | `configs/models.yaml` | Configuration file for models and their weights. |
|
| `--config <path>` | | `configs/models.yaml` | Configuration file for models and their weights. |
|
||||||
| `--iterations <int>` | `-n<int>` | `1` | How many images to generate per prompt. |
|
| `--iterations <int>` | `-n<int>` | `1` | How many images to generate per prompt. |
|
||||||
|
| `--width <int>` | `-W<int>` | `512` | Width of generated image |
|
||||||
|
| `--height <int>` | `-H<int>` | `512` | Height of generated image | `--steps <int>` | `-s<int>` | `50` | How many steps of refinement to apply |
|
||||||
|
| `--strength <float>` | `-s<float>` | `0.75` | For img2img: how hard to try to match the prompt to the initial image. Ranges from 0.0-0.99, with higher values replacing the initial image completely. |
|
||||||
|
| `--fit` | `-F` | `False` | For img2img: scale the init image to fit into the specified -H and -W dimensions |
|
||||||
| `--grid` | `-g` | `False` | Save all image series as a grid rather than individually. |
|
| `--grid` | `-g` | `False` | Save all image series as a grid rather than individually. |
|
||||||
| `--sampler <sampler>` | `-A<sampler>` | `k_lms` | Sampler to use. Use `-h` to get list of available samplers. |
|
| `--sampler <sampler>` | `-A<sampler>` | `k_lms` | Sampler to use. Use `-h` to get list of available samplers. |
|
||||||
| `--seamless` | | `False` | Create interesting effects by tiling elements of the image. |
|
| `--seamless` | | `False` | Create interesting effects by tiling elements of the image. |
|
||||||
@ -106,7 +110,7 @@ overridden on a per-prompt basis (see
|
|||||||
|
|
||||||
| Argument | Shortcut | Default | Description |
|
| Argument | Shortcut | Default | Description |
|
||||||
|--------------------|------------|---------------------|--------------|
|
|--------------------|------------|---------------------|--------------|
|
||||||
| `--weights <path>` | | `None` | Pth to weights file; use `--model stable-diffusion-1.4` instead |
|
| `--weights <path>` | | `None` | Path to weights file; use `--model stable-diffusion-1.4` instead |
|
||||||
| `--laion400m` | `-l` | `False` | Use older LAION400m weights; use `--model=laion400m` instead |
|
| `--laion400m` | `-l` | `False` | Use older LAION400m weights; use `--model=laion400m` instead |
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -119,6 +123,29 @@ overridden on a per-prompt basis (see
|
|||||||
You can either double your slashes (ick): `C:\\path\\to\\my\\file`, or
|
You can either double your slashes (ick): `C:\\path\\to\\my\\file`, or
|
||||||
use Linux/Mac style forward slashes (better): `C:/path/to/my/file`.
|
use Linux/Mac style forward slashes (better): `C:/path/to/my/file`.
|
||||||
|
|
||||||
|
## invokeai.init initialization file
|
||||||
|
|
||||||
|
Place your preferred startup options in a file named `invokeai.init`
|
||||||
|
to have them load automatically at startup time. The file should contain the startup
|
||||||
|
options as you would type them on the command line (`--steps=10
|
||||||
|
--grid`), one argument per line, or a mixture of both using any of
|
||||||
|
the accepted command switch formats:
|
||||||
|
|
||||||
|
!!! example ""
|
||||||
|
|
||||||
|
```bash
|
||||||
|
--web
|
||||||
|
--steps=28
|
||||||
|
--grid
|
||||||
|
-f 0.6 -C 11.0 -A k_euler_a
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that the initialization file only accepts the command line arguments.
|
||||||
|
There are additional arguments that you can provide on the `invoke>` command
|
||||||
|
line (such as `-n` or `--iterations`) that cannot be entered into this file.
|
||||||
|
Also be alert for empty blank lines at the end of the file, which will cause
|
||||||
|
an arguments error at startup time.
|
||||||
|
|
||||||
## List of prompt arguments
|
## List of prompt arguments
|
||||||
|
|
||||||
After the invoke.py script initializes, it will present you with a `invoke>`
|
After the invoke.py script initializes, it will present you with a `invoke>`
|
||||||
|
@ -87,6 +87,7 @@ import json
|
|||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
import shlex
|
import shlex
|
||||||
import copy
|
import copy
|
||||||
import base64
|
import base64
|
||||||
@ -114,7 +115,8 @@ PRECISION_CHOICES = [
|
|||||||
|
|
||||||
# is there a way to pick this up during git commits?
|
# is there a way to pick this up during git commits?
|
||||||
APP_ID = 'invoke-ai/InvokeAI'
|
APP_ID = 'invoke-ai/InvokeAI'
|
||||||
APP_VERSION = 'v2.02'
|
APP_VERSION = 'v2.1.2'
|
||||||
|
INITFILE = 'invokeai.init'
|
||||||
|
|
||||||
class ArgFormatter(argparse.RawTextHelpFormatter):
|
class ArgFormatter(argparse.RawTextHelpFormatter):
|
||||||
# use defined argument order to display usage
|
# use defined argument order to display usage
|
||||||
@ -141,11 +143,15 @@ class ArgFormatter(argparse.RawTextHelpFormatter):
|
|||||||
class PagingArgumentParser(argparse.ArgumentParser):
|
class PagingArgumentParser(argparse.ArgumentParser):
|
||||||
'''
|
'''
|
||||||
A custom ArgumentParser that uses pydoc to page its output.
|
A custom ArgumentParser that uses pydoc to page its output.
|
||||||
|
It also supports reading defaults from an init file.
|
||||||
'''
|
'''
|
||||||
def print_help(self, file=None):
|
def print_help(self, file=None):
|
||||||
text = self.format_help()
|
text = self.format_help()
|
||||||
pydoc.pager(text)
|
pydoc.pager(text)
|
||||||
|
|
||||||
|
def convert_arg_line_to_args(self, arg_line):
|
||||||
|
return shlex.split(arg_line,comments=True)
|
||||||
|
|
||||||
class Args(object):
|
class Args(object):
|
||||||
def __init__(self,arg_parser=None,cmd_parser=None):
|
def __init__(self,arg_parser=None,cmd_parser=None):
|
||||||
'''
|
'''
|
||||||
@ -162,9 +168,13 @@ class Args(object):
|
|||||||
def parse_args(self):
|
def parse_args(self):
|
||||||
'''Parse the shell switches and store.'''
|
'''Parse the shell switches and store.'''
|
||||||
try:
|
try:
|
||||||
self._arg_switches = self._arg_parser.parse_args()
|
sysargs = sys.argv[1:]
|
||||||
|
if os.path.exists(INITFILE):
|
||||||
|
sysargs.insert(0,f'@{INITFILE}')
|
||||||
|
self._arg_switches = self._arg_parser.parse_args(sysargs)
|
||||||
return self._arg_switches
|
return self._arg_switches
|
||||||
except:
|
except Exception as e:
|
||||||
|
print(f'An exception has occurred: {e}')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def parse_cmd(self,cmd_string):
|
def parse_cmd(self,cmd_string):
|
||||||
@ -357,7 +367,7 @@ class Args(object):
|
|||||||
This defines all the arguments used on the command line when you launch
|
This defines all the arguments used on the command line when you launch
|
||||||
the CLI or web backend.
|
the CLI or web backend.
|
||||||
'''
|
'''
|
||||||
parser = argparse.ArgumentParser(
|
parser = PagingArgumentParser(
|
||||||
description=
|
description=
|
||||||
"""
|
"""
|
||||||
Generate images using Stable Diffusion.
|
Generate images using Stable Diffusion.
|
||||||
@ -367,6 +377,7 @@ class Args(object):
|
|||||||
Other command-line arguments are defaults that can usually be overridden
|
Other command-line arguments are defaults that can usually be overridden
|
||||||
prompt the command prompt.
|
prompt the command prompt.
|
||||||
""",
|
""",
|
||||||
|
fromfile_prefix_chars='@',
|
||||||
)
|
)
|
||||||
model_group = parser.add_argument_group('Model selection')
|
model_group = parser.add_argument_group('Model selection')
|
||||||
file_group = parser.add_argument_group('Input/output')
|
file_group = parser.add_argument_group('Input/output')
|
||||||
@ -397,17 +408,6 @@ class Args(object):
|
|||||||
dest='png_compression',
|
dest='png_compression',
|
||||||
help='level of PNG compression, from 0 (none) to 9 (maximum). Default is 6.'
|
help='level of PNG compression, from 0 (none) to 9 (maximum). Default is 6.'
|
||||||
)
|
)
|
||||||
model_group.add_argument(
|
|
||||||
'--sampler',
|
|
||||||
'-A',
|
|
||||||
'-m',
|
|
||||||
dest='sampler_name',
|
|
||||||
type=str,
|
|
||||||
choices=SAMPLER_CHOICES,
|
|
||||||
metavar='SAMPLER_NAME',
|
|
||||||
help=f'Switch to a different sampler. Supported samplers: {", ".join(SAMPLER_CHOICES)}',
|
|
||||||
default='k_lms',
|
|
||||||
)
|
|
||||||
model_group.add_argument(
|
model_group.add_argument(
|
||||||
'-F',
|
'-F',
|
||||||
'--full_precision',
|
'--full_precision',
|
||||||
@ -467,10 +467,61 @@ class Args(object):
|
|||||||
type=str,
|
type=str,
|
||||||
help='Overwrite the filename format. You can use any argument as wildcard enclosed in curly braces. Default is {prefix}.{seed}.png',
|
help='Overwrite the filename format. You can use any argument as wildcard enclosed in curly braces. Default is {prefix}.{seed}.png',
|
||||||
)
|
)
|
||||||
|
render_group.add_argument(
|
||||||
|
'-s',
|
||||||
|
'--steps',
|
||||||
|
type=int,
|
||||||
|
default=50,
|
||||||
|
help='Number of steps'
|
||||||
|
)
|
||||||
|
render_group.add_argument(
|
||||||
|
'-W',
|
||||||
|
'--width',
|
||||||
|
type=int,
|
||||||
|
help='Image width, multiple of 64',
|
||||||
|
)
|
||||||
|
render_group.add_argument(
|
||||||
|
'-H',
|
||||||
|
'--height',
|
||||||
|
type=int,
|
||||||
|
help='Image height, multiple of 64',
|
||||||
|
)
|
||||||
|
render_group.add_argument(
|
||||||
|
'-C',
|
||||||
|
'--cfg_scale',
|
||||||
|
default=7.5,
|
||||||
|
type=float,
|
||||||
|
help='Classifier free guidance (CFG) scale - higher numbers cause generator to "try" harder.',
|
||||||
|
)
|
||||||
|
render_group.add_argument(
|
||||||
|
'--sampler',
|
||||||
|
'-A',
|
||||||
|
'-m',
|
||||||
|
dest='sampler_name',
|
||||||
|
type=str,
|
||||||
|
choices=SAMPLER_CHOICES,
|
||||||
|
metavar='SAMPLER_NAME',
|
||||||
|
help=f'Set the default sampler. Supported samplers: {", ".join(SAMPLER_CHOICES)}',
|
||||||
|
default='k_lms',
|
||||||
|
)
|
||||||
|
render_group.add_argument(
|
||||||
|
'-f',
|
||||||
|
'--strength',
|
||||||
|
type=float,
|
||||||
|
help='img2img strength for noising/unnoising. 0.0 preserves image exactly, 1.0 replaces it completely',
|
||||||
|
)
|
||||||
|
render_group.add_argument(
|
||||||
|
'-T',
|
||||||
|
'-fit',
|
||||||
|
'--fit',
|
||||||
|
action=argparse.BooleanOptionalAction,
|
||||||
|
help='If specified, will resize the input image to fit within the dimensions of width x height (512x512 default)',
|
||||||
|
)
|
||||||
|
|
||||||
render_group.add_argument(
|
render_group.add_argument(
|
||||||
'--grid',
|
'--grid',
|
||||||
'-g',
|
'-g',
|
||||||
action='store_true',
|
action=argparse.BooleanOptionalAction,
|
||||||
help='generate a grid'
|
help='generate a grid'
|
||||||
)
|
)
|
||||||
render_group.add_argument(
|
render_group.add_argument(
|
||||||
@ -599,7 +650,6 @@ class Args(object):
|
|||||||
'-s',
|
'-s',
|
||||||
'--steps',
|
'--steps',
|
||||||
type=int,
|
type=int,
|
||||||
default=50,
|
|
||||||
help='Number of steps'
|
help='Number of steps'
|
||||||
)
|
)
|
||||||
render_group.add_argument(
|
render_group.add_argument(
|
||||||
@ -631,7 +681,6 @@ class Args(object):
|
|||||||
render_group.add_argument(
|
render_group.add_argument(
|
||||||
'-C',
|
'-C',
|
||||||
'--cfg_scale',
|
'--cfg_scale',
|
||||||
default=7.5,
|
|
||||||
type=float,
|
type=float,
|
||||||
help='Classifier free guidance (CFG) scale - higher numbers cause generator to "try" harder.',
|
help='Classifier free guidance (CFG) scale - higher numbers cause generator to "try" harder.',
|
||||||
)
|
)
|
||||||
@ -656,7 +705,7 @@ class Args(object):
|
|||||||
render_group.add_argument(
|
render_group.add_argument(
|
||||||
'--grid',
|
'--grid',
|
||||||
'-g',
|
'-g',
|
||||||
action='store_true',
|
action=argparse.BooleanOptionalAction,
|
||||||
help='generate a grid'
|
help='generate a grid'
|
||||||
)
|
)
|
||||||
render_group.add_argument(
|
render_group.add_argument(
|
||||||
@ -750,8 +799,7 @@ class Args(object):
|
|||||||
'-f',
|
'-f',
|
||||||
'--strength',
|
'--strength',
|
||||||
type=float,
|
type=float,
|
||||||
help='Strength for noising/unnoising. 0.0 preserves image exactly, 1.0 replaces it completely',
|
help='img2img strength for noising/unnoising. 0.0 preserves image exactly, 1.0 replaces it completely',
|
||||||
default=0.75,
|
|
||||||
)
|
)
|
||||||
inpainting_group.add_argument(
|
inpainting_group.add_argument(
|
||||||
'-M',
|
'-M',
|
||||||
|
Loading…
Reference in New Issue
Block a user