#[cfg(feature = "cli")]
use clap::builder::styling::{AnsiColor, Effects, Styles};
#[cfg(feature = "cli")]
use clap::{Args, Parser, Subcommand};
#[cfg(feature = "cli")]
fn styles() -> Styles {
Styles::styled()
.header(AnsiColor::Red.on_default() | Effects::BOLD)
.usage(AnsiColor::Red.on_default() | Effects::BOLD)
.literal(AnsiColor::Blue.on_default() | Effects::BOLD)
.error(AnsiColor::Red.on_default() | Effects::BOLD)
.placeholder(AnsiColor::Green.on_default())
}
#[cfg(feature = "cli")]
#[derive(Parser, Debug, Clone)]
#[command(
author = "Mahmoud Harmouch",
version,
name = "getimg",
propagate_version = true,
styles = styles(),
help_template = r#"{before-help}{name} {version}
{about-with-newline}
{usage-heading} {usage}
{all-args}{after-help}
AUTHORS:
{author}
"#,
about=r#"
📸 GetImg
=========
A command-line tool for interacting with the GetImg AI API.
FUNCTIONALITIES:
- Generate Edited Image: Generate an edited image using the GetImg API.
- Repaint Image: Repaint an image using the GetImg API.
- Generate Image from Text: Generate an image from text using the GetImg API.
- Generate Image from Another Image: Generate an image from another image using the GetImg API.
- Generate Images using ControlNet Conditioning: Generate images using ControlNet conditioning with the GetImg API.
USAGE:
getimg [OPTIONS] <COMMAND>
EXAMPLES:
Generate an edited image:
getimg edit -p "A man riding a horse on Mars." -i image.jpg -s 25 -g 7.5 -e 25 -y 1.5 -o png -n "Disfigured, cartoon, blurry" -c ddim
Repaint an image:
getimg paint -p "An image of a cityscape with neon lights." -i image.png -m edited_image.png -w 512 -a 512 -e 50 -s 5 -g 10.0 -o jpeg -c euler -f 1 -n "Disfigured, cartoon, blurry"
Generate an image from text:
getimg t2i -p "A colorful sunset over the ocean." -w 512 -a 512 -s 5 -e 42 -o png -n "Disfigured, cartoon, blurry"
Generate an image from another image:
getimg i2i -p "Add a forest in the background." -i generated_image.png -s 6 -e 512 -o jpeg -f 0.5 -n "Disfigured, cartoon, blurry"
Generate images using ControlNet conditioning:
getimg cnet -p "A painting of a landscape." -i generated_image.png -f 1.0 -w 512 -a 512 -s 25 -g 7.5 -e 512 -c lms -o png -r canny-1.1 -n "Disfigured, cartoon, blurry"
For more information, visit: github.com/kevin-rs/getimg
"#
)]
pub struct Cli {
#[clap(short, long)]
pub api_key: Option<String>,
#[clap(short, long)]
pub model: Option<String>,
#[clap(subcommand)]
pub cmd: Command,
}
#[cfg(feature = "cli")]
#[derive(Subcommand, Debug, Clone)]
pub enum Command {
Edit(Edit),
#[clap(name = "paint")]
Repaint(Repaint),
#[clap(name = "t2i")]
TextToImage(TextToImage),
#[clap(name = "i2i")]
ImageToImage(ImageToImage),
#[clap(name = "cnet")]
ControlNet(ControlNet),
}
#[cfg(feature = "cli")]
#[derive(Args, Debug, Clone)]
pub struct Edit {
#[clap(short, long)]
pub prompt: String,
#[clap(short, long)]
pub negative_prompt: String,
#[clap(short, long)]
pub image: String,
#[clap(short, long)]
pub guidance: f64,
#[clap(short, long)]
pub steps: usize,
#[clap(short = 'e', long = "eed")]
pub seed: usize,
#[clap(short = 'c', long = "cheduler")]
pub scheduler: String,
#[clap(short, long)]
pub output_format: String,
#[clap(short = 'y', long = "yuidance")]
pub image_guidance: f64,
}
#[cfg(feature = "cli")]
#[derive(Args, Debug, Clone)]
pub struct Repaint {
#[clap(short, long)]
pub prompt: String,
#[clap(short, long)]
pub negative_prompt: String,
#[clap(short, long)]
pub image: String,
#[clap(short, long)]
pub mask_image: String,
#[clap(short, long)]
pub width: usize,
#[clap(short = 'a', long = "hauteur")]
pub height: usize,
#[clap(short, long)]
pub steps: usize,
#[clap(short = 'c', long = "cheduler")]
pub scheduler: String,
#[clap(short = 'e', long = "eed")]
pub seed: usize,
#[clap(short = 'f', long = "force")]
pub strength: f64,
#[clap(short, long)]
pub guidance: f64,
#[clap(short, long)]
pub output_format: String,
}
#[cfg(feature = "cli")]
#[derive(Args, Debug, Clone)]
pub struct TextToImage {
#[clap(short, long)]
pub prompt: String,
#[clap(short, long)]
pub negative_prompt: String,
#[clap(short, long)]
pub width: usize,
#[clap(short = 'a', long = "hauteur")]
pub height: usize,
#[clap(short, long)]
pub steps: usize,
#[clap(short = 'e', long = "eed")]
pub seed: usize,
#[clap(short, long)]
pub output_format: String,
}
#[cfg(feature = "cli")]
#[derive(Args, Debug, Clone)]
pub struct ImageToImage {
#[clap(short, long)]
pub prompt: String,
#[clap(short, long)]
pub negative_prompt: String,
#[clap(short, long)]
pub image: String,
#[clap(short = 'f', long = "force")]
pub strength: f64,
#[clap(short, long)]
pub steps: usize,
#[clap(short, long)]
pub output_format: String,
#[clap(short = 'e', long = "eed")]
pub seed: usize,
}
#[cfg(feature = "cli")]
#[derive(Args, Debug, Clone)]
pub struct ControlNet {
#[clap(short = 'r', long)]
pub net: String,
#[clap(short, long)]
pub prompt: String,
#[clap(short, long)]
pub negative_prompt: String,
#[clap(short, long)]
pub image: String,
#[clap(short = 'f', long = "force")]
pub strength: f64,
#[clap(short, long)]
pub width: usize,
#[clap(short = 'a', long = "hauteur")]
pub height: usize,
#[clap(short, long)]
pub steps: usize,
#[clap(short, long)]
pub guidance: f64,
#[clap(short, long)]
pub output_format: String,
#[clap(short = 'e', long = "eed")]
pub seed: usize,
#[clap(short = 'c', long = "cheduler")]
pub scheduler: String,
}