Spaces:
Running
on
Zero
Running
on
Zero
File size: 2,431 Bytes
5c4e8c1 97256ff 5c4e8c1 97256ff 5c4e8c1 97256ff 5c4e8c1 97256ff 5c4e8c1 97256ff 5c4e8c1 97256ff 5c4e8c1 97256ff 5c4e8c1 97256ff 5c4e8c1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
import argparse
import config as cfg
from generate import generate
def save_images(images, filename="image.png"):
for i, (img, _) in enumerate(images):
name, ext = filename.rsplit(".", 1)
img.save(f"{name}.{ext}" if len(images) == 1 else f"{name}_{i}.{ext}")
def main():
# fmt: off
parser = argparse.ArgumentParser(add_help=False, allow_abbrev=False)
parser.add_argument("prompt", type=str, metavar="PROMPT")
parser.add_argument("-n", "--negative", type=str, metavar="STR", default=cfg.NEGATIVE_PROMPT)
parser.add_argument("-s", "--seed", type=int, metavar="INT", default=cfg.SEED)
parser.add_argument("-i", "--images", type=int, metavar="INT", default=1)
parser.add_argument("-f", "--filename", type=str, metavar="STR", default="image.png")
parser.add_argument("-w", "--width", type=int, metavar="INT", default=cfg.WIDTH)
parser.add_argument("-h", "--height", type=int, metavar="INT", default=cfg.HEIGHT)
parser.add_argument("-m", "--model", type=str, metavar="STR", default=cfg.MODEL)
parser.add_argument("-d", "--deepcache", type=int, metavar="INT", default=cfg.DEEPCACHE_INTERVAL)
parser.add_argument("--style", type=str, metavar="STR", default=cfg.STYLE)
parser.add_argument("--scheduler", type=str, metavar="STR", default=cfg.SCHEDULER)
parser.add_argument("--guidance", type=float, metavar="FLOAT", default=cfg.GUIDANCE_SCALE)
parser.add_argument("--steps", type=int, metavar="INT", default=cfg.INFERENCE_STEPS)
parser.add_argument("--tome", type=float, metavar="FLOAT", default=cfg.TOME_RATIO)
parser.add_argument("--taesd", action="store_true")
parser.add_argument("--clip-skip", action="store_true")
parser.add_argument("--truncate", action="store_true")
parser.add_argument("--karras", action="store_true")
parser.add_argument("--no-increment", action="store_false")
# fmt: on
args = parser.parse_args()
images = generate(
args.prompt,
args.negative,
args.style,
args.seed,
args.model,
args.scheduler,
args.width,
args.height,
args.guidance,
args.steps,
args.images,
args.karras,
args.taesd,
args.clip_skip,
args.truncate,
args.no_increment,
args.deepcache,
args.tome,
)
save_images(images, args.filename)
if __name__ == "__main__":
main()
|