Skip to content

Commit

Permalink
added clamped as a SD launch option
Browse files Browse the repository at this point in the history
  • Loading branch information
LostRuins committed Mar 6, 2024
1 parent e64210e commit 5760bd0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion colab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"if ForceRebuild:\r\n",
" kvers = \"force_rebuild\"\r\n",
"if SDModel and LoadImageModel:\r\n",
" SDCommand = \"--sdconfig sdmodel.safetensors normal 4 noquant\"\r\n",
" SDCommand = \"--sdconfig sdmodel.safetensors clamped 4 quant\"\r\n",
"else:\r\n",
" SDCommand = \"\"\r\n",
"!echo Finding prebuilt binary for {kvers}\r\n",
Expand Down
20 changes: 14 additions & 6 deletions koboldcpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,19 @@ def sd_generate(genparams):
height = (128 if height < 128 else (1024 if height > 1024 else height))

#quick mode
if args.sdconfig and len(args.sdconfig)>1 and args.sdconfig[1]=="quick":
cfg_scale = 1
sample_steps = 7
sample_method = "dpm++ 2m karras"
print("Image generation set to Quick Mode (Low Quality). Step counts, sampler, and cfg scale are fixed.")
if args.sdconfig and len(args.sdconfig)>1:
if args.sdconfig[1]=="quick":
cfg_scale = 1
sample_steps = 7
sample_method = "dpm++ 2m karras"
width = (512 if width > 512 else width)
height = (512 if height > 512 else height)
print("Image generation set to Quick Mode (Low Quality). Step counts, resolution, sampler, and cfg scale are fixed.")
elif args.sdconfig[1]=="clamped":
sample_steps = (40 if sample_steps > 40 else sample_steps)
width = (512 if width > 512 else width)
height = (512 if height > 512 else height)
print("Image generation set to Clamped Mode (For Shared Use). Step counts and resolution are clamped.")

inputs = sd_generation_inputs()
inputs.prompt = prompt.encode("UTF-8")
Expand Down Expand Up @@ -2915,6 +2923,6 @@ def range_checker(arg: str):
parser.add_argument("--quiet", help="Enable quiet mode, which hides generation inputs and outputs in the terminal. Quiet mode is automatically enabled when running --hordeconfig.", action='store_true')
parser.add_argument("--ssl", help="Allows all content to be served over SSL instead. A valid UNENCRYPTED SSL cert and key .pem files must be provided", metavar=('[cert_pem]', '[key_pem]'), nargs='+')
parser.add_argument("--nocertify", help="Allows insecure SSL connections. Use this if you have cert errors and need to bypass certificate restrictions.", action='store_true')
parser.add_argument("--sdconfig", help="Specify a stable diffusion safetensors model to enable image generation. If quick is specified, force optimal generation settings for speed.",metavar=('[sd_filename]', '[normal|quick] [sd_threads] [quant|noquant]'), nargs='+')
parser.add_argument("--sdconfig", help="Specify a stable diffusion safetensors model to enable image generation. If quick is specified, force optimal generation settings for speed.",metavar=('[sd_filename]', '[normal|quick|clamped] [threads] [quant|noquant]'), nargs='+')

main(parser.parse_args(),start_server=True)

0 comments on commit 5760bd0

Please sign in to comment.