2023-12-15 20:31:28 +00:00
|
|
|
"""CLI for AI-powered image generation"""
|
|
|
|
|
2023-02-25 20:32:50 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
import click
|
|
|
|
|
2023-05-08 03:37:15 +00:00
|
|
|
from imaginairy.cli.clickshell_mod import ColorShell, ImagineColorsCommand
|
2023-02-25 20:32:50 +00:00
|
|
|
from imaginairy.cli.colorize import colorize_cmd
|
|
|
|
from imaginairy.cli.describe import describe_cmd
|
|
|
|
from imaginairy.cli.edit import edit_cmd
|
|
|
|
from imaginairy.cli.edit_demo import edit_demo_cmd
|
|
|
|
from imaginairy.cli.imagine import imagine_cmd
|
2023-05-22 07:17:59 +00:00
|
|
|
from imaginairy.cli.run_api import run_server_cmd
|
2023-02-25 20:32:50 +00:00
|
|
|
from imaginairy.cli.upscale import upscale_cmd
|
2023-11-22 18:33:58 +00:00
|
|
|
from imaginairy.cli.videogen import videogen_cmd
|
2023-02-25 20:32:50 +00:00
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
@click.command(
|
|
|
|
prompt="🤖🧠> ",
|
|
|
|
intro="Starting imaginAIry shell...",
|
|
|
|
help_headers_color="yellow",
|
|
|
|
help_options_color="green",
|
|
|
|
context_settings={"max_content_width": 140},
|
|
|
|
cls=ColorShell,
|
|
|
|
)
|
|
|
|
@click.pass_context
|
|
|
|
def aimg(ctx):
|
|
|
|
"""
|
|
|
|
🤖🧠 ImaginAIry.
|
|
|
|
|
|
|
|
Pythonic generation of images via AI
|
|
|
|
"""
|
|
|
|
import sys
|
|
|
|
|
|
|
|
is_shell = len(sys.argv) == 1
|
|
|
|
if is_shell:
|
|
|
|
print(ctx.get_help())
|
|
|
|
|
|
|
|
|
|
|
|
aimg.command_class = ImagineColorsCommand
|
|
|
|
|
|
|
|
|
|
|
|
aimg.add_command(colorize_cmd, name="colorize")
|
|
|
|
aimg.add_command(describe_cmd, name="describe")
|
|
|
|
aimg.add_command(edit_cmd, name="edit")
|
|
|
|
aimg.add_command(edit_demo_cmd, name="edit-demo")
|
|
|
|
aimg.add_command(imagine_cmd, name="imagine")
|
|
|
|
aimg.add_command(upscale_cmd, name="upscale")
|
2023-05-22 07:17:59 +00:00
|
|
|
aimg.add_command(run_server_cmd, name="server")
|
2023-11-22 18:33:58 +00:00
|
|
|
aimg.add_command(videogen_cmd, name="videogen")
|
2023-02-25 20:32:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
@aimg.command()
|
|
|
|
def version():
|
|
|
|
"""Print the version."""
|
|
|
|
from imaginairy.version import get_version
|
|
|
|
|
|
|
|
print(get_version())
|
|
|
|
|
|
|
|
|
|
|
|
@aimg.command("system-info")
|
|
|
|
def system_info():
|
|
|
|
"""
|
|
|
|
Display system information. Submit this when reporting bugs.
|
|
|
|
"""
|
2023-12-05 03:01:51 +00:00
|
|
|
from imaginairy.utils.debug_info import get_debug_info
|
2023-02-25 20:32:50 +00:00
|
|
|
|
2023-12-05 03:01:51 +00:00
|
|
|
debug_info = get_debug_info()
|
|
|
|
|
|
|
|
for k, v in debug_info.items():
|
|
|
|
if k == "nvidia_smi":
|
|
|
|
continue
|
2023-02-25 20:32:50 +00:00
|
|
|
k += ":"
|
|
|
|
click.secho(f"{k: <30} {v}")
|
2023-02-25 21:51:00 +00:00
|
|
|
|
2023-12-05 03:01:51 +00:00
|
|
|
if "nvidia_smi" in debug_info:
|
|
|
|
click.secho(debug_info["nvidia_smi"])
|
|
|
|
|
2023-02-25 21:51:00 +00:00
|
|
|
|
|
|
|
@aimg.command("model-list")
|
|
|
|
def model_list_cmd():
|
|
|
|
"""Print list of available models."""
|
|
|
|
from imaginairy import config
|
|
|
|
|
2023-12-10 22:46:11 +00:00
|
|
|
print("\nWEIGHT NAMES")
|
|
|
|
print(f"{'ALIAS': <25} {'NAME': <25} ")
|
2023-12-08 04:57:55 +00:00
|
|
|
for model_config in config.MODEL_WEIGHT_CONFIGS:
|
2023-12-10 22:46:11 +00:00
|
|
|
print(f"{model_config.aliases[0]: <25} {model_config.name: <25}")
|
2023-02-25 21:51:00 +00:00
|
|
|
|
2023-12-10 22:46:11 +00:00
|
|
|
print("\nCONTROL MODES")
|
|
|
|
print(f"{'ALIAS': <14} {'NAME': <35} {'CONTROL TYPE'}")
|
2023-12-08 04:57:55 +00:00
|
|
|
for control_mode in config.CONTROL_CONFIGS:
|
2023-02-25 21:51:00 +00:00
|
|
|
print(
|
2023-12-10 22:46:11 +00:00
|
|
|
f"{control_mode.aliases[0]: <14} {control_mode.name: <35} {control_mode.control_type}"
|
2023-02-25 21:51:00 +00:00
|
|
|
)
|
2023-02-27 04:07:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-09-29 08:13:50 +00:00
|
|
|
aimg()
|