|
5 | 5 | import click
|
6 | 6 | from click_shell import shell
|
7 | 7 |
|
8 |
| -from imaginairy import LazyLoadingImage, config, generate_caption |
| 8 | +from imaginairy import LazyLoadingImage, __version__, config, generate_caption |
9 | 9 | from imaginairy.api import imagine_image_files
|
10 |
| -from imaginairy.config import MODEL_SHORT_NAMES |
11 | 10 | from imaginairy.enhancers.prompt_expansion import expand_prompts
|
12 | 11 | from imaginairy.log_utils import configure_logging
|
13 | 12 | from imaginairy.samplers import SAMPLER_TYPE_OPTIONS
|
|
198 | 197 | @click.option(
|
199 | 198 | "--model-weights-path",
|
200 | 199 | "--model",
|
201 |
| - help=f"Model to use. Should be one of {', '.join(MODEL_SHORT_NAMES)}, or a path to custom weights.", |
| 200 | + help=f"Model to use. Should be one of {', '.join(config.MODEL_SHORT_NAMES)}, or a path to custom weights.", |
202 | 201 | show_default=True,
|
203 | 202 | default=config.DEFAULT_MODEL,
|
204 | 203 | )
|
|
215 | 214 | default=None,
|
216 | 215 | multiple=True,
|
217 | 216 | )
|
| 217 | +@click.option( |
| 218 | + "--version", |
| 219 | + default=False, |
| 220 | + is_flag=True, |
| 221 | + help="Print the version and exit.", |
| 222 | +) |
218 | 223 | @click.pass_context
|
219 | 224 | def imagine_cmd(
|
220 | 225 | ctx,
|
@@ -249,11 +254,16 @@ def imagine_cmd(
|
249 | 254 | model_weights_path,
|
250 | 255 | model_config_path,
|
251 | 256 | prompt_library_path,
|
| 257 | + version, # noqa |
252 | 258 | ):
|
253 | 259 | """Have the AI generate images. alias:imagine."""
|
254 | 260 | if ctx.invoked_subcommand is not None:
|
255 | 261 | return
|
256 | 262 |
|
| 263 | + if version: |
| 264 | + print(__version__) |
| 265 | + return |
| 266 | + |
257 | 267 | if quiet:
|
258 | 268 | log_level = "ERROR"
|
259 | 269 | configure_logging(log_level)
|
@@ -329,6 +339,12 @@ def aimg():
|
329 | 339 | pass
|
330 | 340 |
|
331 | 341 |
|
| 342 | +@aimg.command() |
| 343 | +def version(): |
| 344 | + """Print the version.""" |
| 345 | + print(__version__) |
| 346 | + |
| 347 | + |
332 | 348 | @click.argument("image_filepaths", nargs=-1)
|
333 | 349 | @aimg.command()
|
334 | 350 | def describe(image_filepaths):
|
@@ -381,7 +397,7 @@ def describe(image_filepaths):
|
381 | 397 | "--model-weights-path",
|
382 | 398 | "--model",
|
383 | 399 | "model",
|
384 |
| - help=f"Model to use. Should be one of {', '.join(MODEL_SHORT_NAMES)}, or a path to custom weights.", |
| 400 | + help=f"Model to use. Should be one of {', '.join(config.MODEL_SHORT_NAMES)}, or a path to custom weights.", |
385 | 401 | show_default=True,
|
386 | 402 | default=config.DEFAULT_MODEL,
|
387 | 403 | )
|
|
0 commit comments