@ -11,44 +11,56 @@ Check the [custom scripts](https://github.com/AUTOMATIC1111/stable-diffusion-web
- One click install and run script (but you still must install python and git)
- One click install and run script (but you still must install python and git)
- Outpainting
- Outpainting
- Inpainting
- Inpainting
- Prompt matrix
- Prompt Matrix
- Stable Diffusion upscale
- Stable Diffusion Upscale
- Attention
- Attention, specify parts of text that the model should pay more attention to
- Loopback
- a man in a ((tuxedo)) - will pay more attention to tuxedo
- X/Y plot
- a man in a (tuxedo:1.21) - alternative syntax
- Loopback, run img2img processing multiple times
- X/Y plot, a way to draw a 2 dimensional plot of images with different parameters
- Textual Inversion
- Textual Inversion
- have as many embeddings as you want and use any names you like for them
- use multiple embeddings with different numbers of vectors per token
- works with half precision floating point numbers
- Extras tab with:
- Extras tab with:
- GFPGAN, neural network that fixes faces
- GFPGAN, neural network that fixes faces
- CodeFormer, face restoration tool as an alternative to GFPGAN
- CodeFormer, face restoration tool as an alternative to GFPGAN
- RealESRGAN, neural network upscaler
- RealESRGAN, neural network upscaler
- ESRGAN, neural network with a lot of third party models
- ESRGAN, neural network upscaler with a lot of third party models
- SwinIR, neural network upscaler
- SwinIR, neural network upscaler
- LDSR, Latent diffusion super resolution upscaling
- LDSR, Latent diffusion super resolution upscaling
- Resizing aspect ratio options
- Resizing aspect ratio options
- Sampling method selection
- Sampling method selection
- Interrupt processing at any time
- Interrupt processing at any time
- 4GB video card support
- 4GB video card support (also reports of 2GB working)
- Correct seeds for batches
- Correct seeds for batches
- Prompt length validation
- Prompt length validation
- Generation parameters added as text to PNG
- get length of prompt in tokens as you type
- Tab to view an existing picture's generation parameters
- get a warning after generation if some text was truncated
- Generation parameters
- parameters you used to generate images are saved with that image
- in PNG chunks for PNG, in EXIF for JPEG
- can drag the image to PNG info tab to restore generation parameters and automatically copy them into UI
- can be disabled in settings
- Settings page
- Settings page
- Running custom code from UI
- Running arbitrary python code from UI (must run with --allow-code to enable)
- Mouseover hints for most UI elements
- Mouseover hints for most UI elements
- Possible to change defaults/mix/max/step values for UI elements via text config
- Possible to change defaults/mix/max/step values for UI elements via text config
- Random artist button
- Random artist button
- Tiling support: UI checkbox to create images that can be tiled like textures
- Tiling support, a checkbox to create images that can be tiled like textures
- Progress bar and live image generation preview
- Progress bar and live image generation preview
- Negative prompt
- Negative prompt, an extra text field that allows you to list what you don't want to see in generated image
- Styles
- Styles, a way to save part of prompt and easily apply them via dropdown later
- Variations
- Variations, a way to generate same image but with tiny differences
- Seed resizing
- Seed resizing, a way to generate same image but at slightly different resolution
- CLIP interrogator
- CLIP interrogator, a button that tries to guess prompt from an image
- Prompt Editing
- Prompt Editing, a way to change prompt mid-generation, say to start making a watermelon and switch to anime girl midway
- Batch Processing
- Batch Processing, process a group of files using img2img
- Img2img Alternative
- Img2img Alternative
- Highres Fix
- Highres Fix, a convenience option to produce high resolution pictures in one click without usual distortions
- LDSR Upscaling
- Reloading checkpoints on the fly
- Checkpoint Merger, a tab that allows you to merge two checkpoints into one
- [Custom scripts](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Custom-Scripts) with many extensions from community
## Installation and Running
## Installation and Running
Make sure the required [dependencies](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Dependencies) are met and follow the instructions available for both [NVidia](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-NVidia-GPUs) (recommended) and [AMD](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-AMD-GPUs) GPUs.
Make sure the required [dependencies](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Dependencies) are met and follow the instructions available for both [NVidia](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-NVidia-GPUs) (recommended) and [AMD](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-AMD-GPUs) GPUs.
@ -101,6 +113,7 @@ The documentation was moved from this README over to the project's [wiki](https:
"\u267b\ufe0f":"Reuse seed from last generation, mostly useful if it was randomed",
"\u267b\ufe0f":"Reuse seed from last generation, mostly useful if it was randomed",
"\u{1f3a8}":"Add a random artist to the prompt.",
"\u{1f3a8}":"Add a random artist to the prompt.",
"\u2199\ufe0f":"Read generation parameters from prompt into user interface.",
"\u2199\ufe0f":"Read generation parameters from prompt into user interface.",
"\uD83D\uDCC2":"Open images output directory",
"\u{1f4c2}":"Open images output directory",
"Inpaint a part of image":"Draw a mask over an image, and the script will regenerate the masked area with content according to prompt",
"Inpaint a part of image":"Draw a mask over an image, and the script will regenerate the masked area with content according to prompt",
"SD upscale":"Upscale image normally, split result into tiles, improve each tile using img2img, merge whole image back",
"SD upscale":"Upscale image normally, split result into tiles, improve each tile using img2img, merge whole image back",
@ -47,6 +47,7 @@ titles = {
"Custom code":"Run Python code. Advanced user only. Must run program with --allow-code for this to work",
"Custom code":"Run Python code. Advanced user only. Must run program with --allow-code for this to work",
"Prompt S/R":"Separate a list of words with commas, and the first word will be used as a keyword: script will search for this word in the prompt, and replace it with others",
"Prompt S/R":"Separate a list of words with commas, and the first word will be used as a keyword: script will search for this word in the prompt, and replace it with others",
"Prompt order":"Separate a list of words with commas, and the script will make a variation of prompt with those words for their every possible order",
"Tiling":"Produce an image that can be tiled.",
"Tiling":"Produce an image that can be tiled.",
"Tile overlap":"For SD upscale, how much overlap in pixels should there be between tiles. Tiles overlap so that when they are merged back into one picture, there is no clearly visible seam.",
"Tile overlap":"For SD upscale, how much overlap in pixels should there be between tiles. Tiles overlap so that when they are merged back into one picture, there is no clearly visible seam.",
run(f'"{git}" -C {dir} fetch',f"Fetching updates for {name}...",f"Couldn't fetch {name}")
run(f'"{git}" -C {dir} checkout {commithash}',f"Checking out commint for {name} with hash: {commithash}...",f"Couldn't checkout commit {commithash} for {name}")
return
return
run(f'"{git}" clone "{url}""{dir}"',f"Cloning {name} into {dir}...",f"Couldn't clone {name}")
run(f'"{git}" clone "{url}""{dir}"',f"Cloning {name} into {dir}...",f"Couldn't clone {name}")
# a prompt like this: "fantasy landscape with a [mountain:lake:0.25] and [an oak:a christmas tree:0.75][ in foreground::0.6][ in background:0.25] [shoddy:masterful:0.5]"
# a prompt like this: "fantasy landscape with a [mountain:lake:0.25] and [an oak:a christmas tree:0.75][ in foreground::0.6][ in background:0.25] [shoddy:masterful:0.5]"
# will be represented with prompt_schedule like this (assuming steps=100):
# will be represented with prompt_schedule like this (assuming steps=100):
@ -23,71 +11,112 @@ re_prompt = re.compile(r'''
# [75, 'fantasy landscape with a lake and an oak in background masterful']
# [75, 'fantasy landscape with a lake and an oak in background masterful']
# [100, 'fantasy landscape with a lake and a christmas tree in background masterful']
# [100, 'fantasy landscape with a lake and a christmas tree in background masterful']
"""converts a list of prompts into a list of prompt schedules - each schedule is a list of ScheduledPromptConditioning, specifying the comdition (cond),
parser.add_argument("--config",type=str,default=os.path.join(sd_path,"configs/stable-diffusion/v1-inference.yaml"),help="path to config which constructs model",)
parser.add_argument("--config",type=str,default=os.path.join(sd_path,"configs/stable-diffusion/v1-inference.yaml"),help="path to config which constructs model",)
parser.add_argument("--ckpt",type=str,default=sd_model_file,help="path to checkpoint of stable diffusion model; this checkpoint will be added to the list of checkpoints and loaded by default if you don't have a checkpoint selected in settings",)
parser.add_argument("--ckpt",type=str,default=sd_model_file,help="path to checkpoint of stable diffusion model; if specified, this checkpoint will be added to the list of checkpoints and loaded",)
parser.add_argument("--ckpt-dir",type=str,default=None,help="Path to directory with stable diffusion checkpoints")
parser.add_argument("--ckpt-dir",type=str,default=None,help="Path to directory with stable diffusion checkpoints")
parser.add_argument("--unload-gfpgan",action='store_true',help="does not do anything.")
parser.add_argument("--unload-gfpgan",action='store_true',help="does not do anything.")
parser.add_argument("--precision",type=str,help="evaluate at this precision",choices=["full","autocast"],default="autocast")
parser.add_argument("--precision",type=str,help="evaluate at this precision",choices=["full","autocast"],default="autocast")
parser.add_argument("--share",action='store_true',help="use share=True for gradio and make the UI accessible through their site (doesn't work for me but you might have better luck)")
parser.add_argument("--share",action='store_true',help="use share=True for gradio and make the UI accessible through their site (doesn't work for me but you might have better luck)")
parser.add_argument("--codeformer-models-path",type=str,help="Path to directory with codeformer model file(s).",default=os.path.join(model_path,'Codeformer'))
parser.add_argument("--codeformer-models-path",type=str,help="Path to directory with codeformer model file(s).",default=os.path.join(models_path,'Codeformer'))
parser.add_argument("--gfpgan-models-path",type=str,help="Path to directory with GFPGAN model file(s).",default=os.path.join(model_path,'GFPGAN'))
parser.add_argument("--gfpgan-models-path",type=str,help="Path to directory with GFPGAN model file(s).",default=os.path.join(models_path,'GFPGAN'))
parser.add_argument("--esrgan-models-path",type=str,help="Path to directory with ESRGAN model file(s).",default=os.path.join(model_path,'ESRGAN'))
parser.add_argument("--esrgan-models-path",type=str,help="Path to directory with ESRGAN model file(s).",default=os.path.join(models_path,'ESRGAN'))
parser.add_argument("--bsrgan-models-path",type=str,help="Path to directory with BSRGAN model file(s).",default=os.path.join(model_path,'BSRGAN'))
parser.add_argument("--bsrgan-models-path",type=str,help="Path to directory with BSRGAN model file(s).",default=os.path.join(models_path,'BSRGAN'))
parser.add_argument("--realesrgan-models-path",type=str,help="Path to directory with RealESRGAN model file(s).",default=os.path.join(model_path,'RealESRGAN'))
parser.add_argument("--realesrgan-models-path",type=str,help="Path to directory with RealESRGAN model file(s).",default=os.path.join(models_path,'RealESRGAN'))
parser.add_argument("--swinir-models-path",type=str,help="Path to directory with SwinIR model file(s).",default=os.path.join(model_path,'SwinIR'))
parser.add_argument("--scunet-models-path",type=str,help="Path to directory with ScuNET model file(s).",default=os.path.join(models_path,'ScuNET'))
parser.add_argument("--ldsr-models-path",type=str,help="Path to directory with LDSR model file(s).",default=os.path.join(model_path,'LDSR'))
parser.add_argument("--swinir-models-path",type=str,help="Path to directory with SwinIR model file(s).",default=os.path.join(models_path,'SwinIR'))
parser.add_argument("--ldsr-models-path",type=str,help="Path to directory with LDSR model file(s).",default=os.path.join(models_path,'LDSR'))
parser.add_argument("--opt-split-attention",action='store_true',help="force-enables cross-attention layer optimization. By default, it's on for torch.cuda and off for other torch devices.")
parser.add_argument("--opt-split-attention",action='store_true',help="force-enables cross-attention layer optimization. By default, it's on for torch.cuda and off for other torch devices.")
parser.add_argument("--opt-split-attention-v1",action='store_true',help="enable older version of split attention optimization that does not consume all the VRAM it can find")
parser.add_argument("--opt-split-attention-v1",action='store_true',help="enable older version of split attention optimization that does not consume all the VRAM it can find")
parser.add_argument("--use-cpu",nargs='+',choices=['SD','GFPGAN','BSRGAN','ESRGAN','SCUNet','CodeFormer'],help="use CPU as torch device for specified modules",default=[])
parser.add_argument("--listen",action='store_true',help="launch gradio with 0.0.0.0 as server name, allowing to respond to network requests")
parser.add_argument("--listen",action='store_true',help="launch gradio with 0.0.0.0 as server name, allowing to respond to network requests")
parser.add_argument("--port",type=int,help="launch gradio with given server port, you need root/admin rights for ports < 1024, defaults to 7860 if available",default=None)
parser.add_argument("--port",type=int,help="launch gradio with given server port, you need root/admin rights for ports < 1024, defaults to 7860 if available",default=None)
parser.add_argument("--show-negative-prompt",action='store_true',help="does not do anything",default=False)
parser.add_argument("--show-negative-prompt",action='store_true',help="does not do anything",default=False)
@ -53,13 +55,21 @@ parser.add_argument("--hide-ui-dir-config", action='store_true', help="hide dire
parser.add_argument("--ui-settings-file",type=str,help="filename to use for ui settings",default=os.path.join(script_path,'config.json'))
parser.add_argument("--ui-settings-file",type=str,help="filename to use for ui settings",default=os.path.join(script_path,'config.json'))
parser.add_argument("--gradio-debug",action='store_true',help="launch gradio with --debug option")
parser.add_argument("--gradio-debug",action='store_true',help="launch gradio with --debug option")
parser.add_argument("--gradio-auth",type=str,help='set gradio authentication like "username:password"; or comma-delimit multiple like "u1:p1,u2:p2,u3:p3"',default=None)
parser.add_argument("--gradio-auth",type=str,help='set gradio authentication like "username:password"; or comma-delimit multiple like "u1:p1,u2:p2,u3:p3"',default=None)
parser.add_argument("--gradio-img2img-tool",type=str,help='gradio image uploader tool: can be either editor for ctopping, or color-sketch for drawing',choices=["color-sketch","editor"],default="editor")
parser.add_argument("--opt-channelslast",action='store_true',help="change memory type for stable diffusion to channels last")
parser.add_argument("--opt-channelslast",action='store_true',help="change memory type for stable diffusion to channels last")
parser.add_argument("--styles-file",type=str,help="filename to use for styles",default=os.path.join(script_path,'styles.csv'))
parser.add_argument("--styles-file",type=str,help="filename to use for styles",default=os.path.join(script_path,'styles.csv'))
parser.add_argument("--autolaunch",action='store_true',help="open the webui URL in the system's default browser upon launch",default=False)
parser.add_argument("--autolaunch",action='store_true',help="open the webui URL in the system's default browser upon launch",default=False)
parser.add_argument("--use-textbox-seed",action='store_true',help="use textbox for seeds in UI (no up/down, but possible to input long seeds)",default=False)
parser.add_argument("--use-textbox-seed",action='store_true',help="use textbox for seeds in UI (no up/down, but possible to input long seeds)",default=False)
parser.add_argument("--disable-console-progressbars",action='store_true',help="do not output progressbars to console",default=False)
parser.add_argument("--enable-console-prompts",action='store_true',help="print prompts to console when generating with txt2img and img2img",default=False)
"save_images_before_color_correction":OptionInfo(False,"Save a copy of image before applying color correction to img2img results"),
"save_images_before_color_correction":OptionInfo(False,"Save a copy of image before applying color correction to img2img results"),
"img2img_fix_steps":OptionInfo(False,"With img2img, do exactly the amount of steps the slider specifies (normally you'd do less with less denoising)."),
"img2img_fix_steps":OptionInfo(False,"With img2img, do exactly the amount of steps the slider specifies (normally you'd do less with less denoising)."),
"enable_quantization":OptionInfo(False,"Enable quantization in K samplers for sharper and cleaner results. This may change existing seeds. Requires restart to apply."),
"enable_quantization":OptionInfo(False,"Enable quantization in K samplers for sharper and cleaner results. This may change existing seeds. Requires restart to apply."),
"enable_emphasis":OptionInfo(True,"Eemphasis: use (text) to make model pay more attention to text and [text] to make it pay less attention"),
"enable_emphasis":OptionInfo(True,"Emphasis: use (text) to make model pay more attention to text and [text] to make it pay less attention"),
"use_old_emphasis_implementation":OptionInfo(False,"Use old emphasis implementation. Can be useful to reproduce old seeds."),
"use_old_emphasis_implementation":OptionInfo(False,"Use old emphasis implementation. Can be useful to reproduce old seeds."),
"enable_batch_seeds":OptionInfo(True,"Make K-diffusion samplers produce same images in a batch as when making a single image"),
"enable_batch_seeds":OptionInfo(True,"Make K-diffusion samplers produce same images in a batch as when making a single image"),
"show_progress_every_n_steps":OptionInfo(0,"Show show image creation progress every N sampling steps. Set 0 to disable.",gr.Slider,{"minimum":0,"maximum":32,"step":1}),
"show_progress_every_n_steps":OptionInfo(0,"Show show image creation progress every N sampling steps. Set 0 to disable.",gr.Slider,{"minimum":0,"maximum":32,"step":1}),
"return_grid":OptionInfo(True,"Show grid in results for web"),
"return_grid":OptionInfo(True,"Show grid in results for web"),
"do_not_show_images":OptionInfo(False,"Do not show any images in results for web"),
"add_model_hash_to_info":OptionInfo(True,"Add model hash to generation information"),
"add_model_hash_to_info":OptionInfo(True,"Add model hash to generation information"),
"font":OptionInfo("","Font for image grids that have text"),
"font":OptionInfo("","Font for image grids that have text"),
"js_modal_lightbox":OptionInfo(True,"Enable full page image viewer"),
"js_modal_lightbox":OptionInfo(True,"Enable full page image viewer"),
"js_modal_lightbox_initialy_zoomed":OptionInfo(True,"Show images zoomed in by default in full page image viewer"),
"js_modal_lightbox_initialy_zoomed":OptionInfo(True,"Show images zoomed in by default in full page image viewer"),
"show_progress_in_title":OptionInfo(True,"Show generation progress in window title."),
"eta_ddim":OptionInfo(0.0,"eta (noise multiplier) for DDIM",gr.Slider,{"minimum":0.0,"maximum":1.0,"step":0.01}),
"hide_samplers":OptionInfo([],"Hide samplers in user interface (requires restart)",gr.CheckboxGroup,lambda:{"choices":[x.nameforxinsd_samplers.all_samplers]}),
"eta_ancestral":OptionInfo(1.0,"eta (noise multiplier) for ancestral samplers",gr.Slider,{"minimum":0.0,"maximum":1.0,"step":0.01}),
"eta_ddim":OptionInfo(0.0,"eta (noise multiplier) for DDIM",gr.Slider,{"minimum":0.0,"maximum":1.0,"step":0.01}),
"ddim_discretize":OptionInfo('uniform',"img2img DDIM discretize",gr.Radio,{"choices":['uniform','quad']}),
"eta_ancestral":OptionInfo(1.0,"eta (noise multiplier) for ancestral samplers",gr.Slider,{"minimum":0.0,"maximum":1.0,"step":0.01}),
#quick dictionary to class object conversion. Its neccesary due apply_filename_pattern requiring it
classMyObject:
def__init__(self,d=None):
ifdisnotNone:
forkey,valueind.items():
setattr(self,key,value)
data=json.loads(js_data)
data=json.loads(js_data)
p=MyObject(data)
path=opts.outdir_save
save_to_dirs=opts.use_save_to_dirs_for_ui
extension:str=opts.samples_format
start_index=0
ifindex>-1andopts.save_selected_onlyand(index>=data["index_of_first_image"]):# ensures we are looking at a specific non-grid picture, and we have save_selected_only
ifindex>-1andopts.save_selected_onlyand(index>=data["index_of_first_image"]):# ensures we are looking at a specific non-grid picture, and we have save_selected_only
init_img=gr.Image(label="Image for img2img", show_label=False,source="upload",interactive=True,type="pil")
init_img=gr.Image(label="Image for img2img",elem_id="img2img_image",show_label=False,source="upload",interactive=True,type="pil",tool=cmd_opts.gradio_img2img_tool)
withgr.TabItem('Inpaint',id='inpaint'):
withgr.TabItem('Inpaint',id='inpaint'):
init_img_with_mask=gr.Image(label="Image for inpainting with mask",show_label=False,elem_id="img2maskimg",source="upload",interactive=True,type="pil",tool="sketch",image_mode="RGBA")
init_img_with_mask=gr.Image(label="Image for inpainting with mask",show_label=False,elem_id="img2maskimg",source="upload",interactive=True,type="pil",tool="sketch",image_mode="RGBA")
hidden='<br>Disabled when launched with --hide-ui-dir-config.'ifshared.cmd_opts.hide_ui_dir_configelse''
hidden='<br>Disabled when launched with --hide-ui-dir-config.'ifshared.cmd_opts.hide_ui_dir_configelse''
gr.HTML(f"<p class=\"text-gray-500\">Process images in a directory on the same machine where the server is running.{hidden}</p>")
gr.HTML(f"<p class=\"text-gray-500\">Process images in a directory on the same machine where the server is running.<br>Use an empty output directory to save pictures normally instead of writing to the output directory.{hidden}</p>")
print("Error loading/saving model file:",file=sys.stderr)
print("Error loading/saving model file:",file=sys.stderr)
print(traceback.format_exc(),file=sys.stderr)
print(traceback.format_exc(),file=sys.stderr)
modules.sd_models.list_models()#To remove the potentially missing models from the list
modules.sd_models.list_models()# to remove the potentially missing models from the list
return["Error loading/saving model file. It doesn't exist or the name contains illegal characters"]+[gr.Dropdown.update(choices=modules.sd_models.checkpoint_tiles())for_inrange(3)]
return["Error loading/saving model file. It doesn't exist or the name contains illegal characters"]+[gr.Dropdown.update(choices=modules.sd_models.checkpoint_tiles())for_inrange(3)]
returnresults
returnresults
@ -1206,12 +1403,12 @@ for filename in sorted(os.listdir(jsdir)):
javascript+=f"\n<script>{jsfile.read()}</script>"
javascript+=f"\n<script>{jsfile.read()}</script>"
def template_response(*args,**kwargs):
if 'gradio_routes_templates_response'notinglobals():