adamelliotfields commited on
Commit
5f39fb6
·
verified ·
1 Parent(s): a46e137

Remove CLI

Browse files
Files changed (2) hide show
  1. README.md +0 -3
  2. cli.py +0 -92
README.md CHANGED
@@ -88,9 +88,6 @@ pip install -r requirements.txt torch==2.4.0 torchvision==0.19.0
88
 
89
  # gradio
90
  python app.py --port 7860
91
-
92
- # cli
93
- python cli.py 'an astronaut riding a horse on mars'
94
  ```
95
 
96
  ## Development
 
88
 
89
  # gradio
90
  python app.py --port 7860
 
 
 
91
  ```
92
 
93
  ## Development
cli.py DELETED
@@ -1,92 +0,0 @@
1
- # CLI
2
- # usage: python cli.py 'colorful calico cat artstation'
3
- import argparse
4
- import asyncio
5
- from warnings import filterwarnings
6
-
7
- from diffusers.utils import logging as diffusers_logging
8
- from transformers import logging as transformers_logging
9
-
10
- from lib import Config, async_call, generate
11
-
12
- filterwarnings("ignore", category=FutureWarning, module="diffusers")
13
- filterwarnings("ignore", category=FutureWarning, module="transformers")
14
-
15
- # reduce verbosity but don't disable progress bars
16
- diffusers_logging.set_verbosity_error()
17
- transformers_logging.set_verbosity_error()
18
-
19
-
20
- def save_images(images, filename="image.png"):
21
- for i, (img, _) in enumerate(images):
22
- name, ext = filename.rsplit(".", 1)
23
- img.save(f"{name}.{ext}" if len(images) == 1 else f"{name}_{i}.{ext}")
24
-
25
-
26
- async def main():
27
- # fmt: off
28
- parser = argparse.ArgumentParser(add_help=False, allow_abbrev=False)
29
- parser.add_argument("prompt", type=str, metavar="PROMPT")
30
- parser.add_argument("-n", "--negative", type=str, metavar="STR", default="")
31
- parser.add_argument("-e", "--embeddings", type=str, metavar="STR", default="")
32
- parser.add_argument("-s", "--seed", type=int, metavar="INT", default=Config.SEED)
33
- parser.add_argument("-i", "--images", type=int, metavar="INT", default=1)
34
- parser.add_argument("-f", "--filename", type=str, metavar="STR", default="image.png")
35
- parser.add_argument("-w", "--width", type=int, metavar="INT", default=Config.WIDTH)
36
- parser.add_argument("-h", "--height", type=int, metavar="INT", default=Config.HEIGHT)
37
- parser.add_argument("-m", "--model", type=str, metavar="STR", default=Config.MODEL)
38
- parser.add_argument("-d", "--deepcache", type=int, metavar="INT", default=Config.DEEPCACHE_INTERVAL)
39
- parser.add_argument("--lora-1", type=str, metavar="STR", default="")
40
- parser.add_argument("--lora-1-weight", type=float, metavar="FLOAT", default=0.0)
41
- parser.add_argument("--lora-2", type=str, metavar="STR", default="")
42
- parser.add_argument("--lora-2-weight", type=float, metavar="FLOAT", default=0.0)
43
- parser.add_argument("--scale", type=int, metavar="INT", choices=Config.SCALES, default=Config.SCALE)
44
- parser.add_argument("--style", type=str, metavar="STR", default=Config.STYLE)
45
- parser.add_argument("--scheduler", type=str, metavar="STR", default=Config.SCHEDULER)
46
- parser.add_argument("--guidance", type=float, metavar="FLOAT", default=Config.GUIDANCE_SCALE)
47
- parser.add_argument("--steps", type=int, metavar="INT", default=Config.INFERENCE_STEPS)
48
- parser.add_argument("--image-strength", type=float, metavar="FLOAT", default=Config.DENOISING_STRENGTH)
49
- parser.add_argument("--image", type=str, metavar="STR")
50
- parser.add_argument("--ip-image", type=str, metavar="STR")
51
- parser.add_argument("--ip-face", action="store_true")
52
- parser.add_argument("--taesd", action="store_true")
53
- parser.add_argument("--clip-skip", action="store_true")
54
- parser.add_argument("--karras", action="store_true")
55
- parser.add_argument("--freeu", action="store_true")
56
- # fmt: on
57
-
58
- args = parser.parse_args()
59
- images = await async_call(
60
- generate,
61
- args.prompt,
62
- args.negative,
63
- args.image,
64
- args.ip_image,
65
- args.ip_face,
66
- args.lora_1,
67
- args.lora_1_weight,
68
- args.lora_2,
69
- args.lora_2_weight,
70
- args.embeddings.split(",") if args.embeddings else [],
71
- args.style,
72
- args.seed,
73
- args.model,
74
- args.scheduler,
75
- args.width,
76
- args.height,
77
- args.guidance,
78
- args.steps,
79
- args.image_strength,
80
- args.deepcache,
81
- args.scale,
82
- args.images,
83
- args.karras,
84
- args.taesd,
85
- args.freeu,
86
- args.clip_skip,
87
- )
88
- save_images(images, args.filename)
89
-
90
-
91
- if __name__ == "__main__":
92
- asyncio.run(main())