Giter Club home page Giter Club logo

getimg's Introduction

๐Ÿ“ธ GetImg

CircleCI Crates.io docs License

๐Ÿ“ธ GetImg: A CLI, SDK for interacting with the GetImg API, enabling image generation and manipulation through various endpoints.

๐Ÿ“– Table of Contents

๐Ÿš€ Installation

To install the getimg CLI, use the following Cargo command:

cargo install --locked getimg --all-features

โœจ Features

  • Interact with the GetImg API from the command line interface.
  • Generate and manipulate images using various endpoints.
  • Perform text-to-image and image-to-image generation.
  • Repaint images or generate edited images based on prompts.
  • Utilize ControlNet conditioning for image generation.

Usage

Before using the getimg CLI, make sure to set the following environment variable:

export GETIMG_API_KEY=<your_getimg_api_key>

Generate an API key from the GetImg Dashboard.

โŒจ Usage as CLI

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"

๐ŸŽจ Options

Option Description
--api-key Specify the API key for accessing the GetImg API.
--model Specify the model to use for image generation.

๐Ÿ›  Subcommands

Subcommand Description
edit Generate an edited image.
paint Repaint an image based on prompts.
t2i Generate an image from text.
i2i Generate an image from another image.
cnet Generate images using ControlNet conditioning.

โœจ Usage as Crate

  1. Add the getimg crate:

    [dependencies]
    getimg = "0.0.1"
  2. Use the provided structs and methods to interact with the GetImg API in your Rust project.

    use anyhow::Result;
    use getimg::client::Client;
    use getimg::utils::save_image;
    use std::env;
    
    #[tokio::main]
    async fn main() -> Result<()> {
        // Example usage
        let api_key = env::var("GETIMG_API_KEY").unwrap_or_default().to_owned();
        let text_prompt = "a kanban-style task board with three columns: To Do, In Progress, and Done. Each column contains a list of tasks, with the To Do column having the most tasks and the Done column having the fewest. The tasks are color-coded, with the To Do tasks being red, the In Progress tasks being yellow, and the Done tasks being green. The board also has a header that includes the title \"To Do List\" and a search bar.";
        let negative_prompt = Some("Disfigured, cartoon, blurry");
    
        // Create a new instance of the GetIMG Client
        let mut client = Client::new(&api_key, "lcm-realistic-vision-v5-1");
        println!("{:?}", client);
    
        // Generate image from text prompt
        let text_response = client
            .generate_image_from_text(
                text_prompt,
                1024,
                1024,
                4,
                "jpeg",
                negative_prompt,
                Some(512),
            )
            .await?;
    
        // Save text response image to file
        save_image(&text_response.image, "text_response.jpg")?;
    
        // Generate image from image prompt
        let image_response = client
            .generate_image_from_image(
                "a photo of an astronaut riding a horse on mars",
                &text_response.image,
                4,
                512,
                "jpeg",
                negative_prompt,
                Some(0.5),
            )
            .await?;
    
        // Save image response image to file
        save_image(&image_response.image, "image_response.png")?;
    
        let controlnet_response = client
            .generate_image_using_controlnet(
                "softedge-1.1",
                "a photo of an astronaut riding a horse on mars",
                "Disfigured, cartoon, blurry",
                &image_response.image,
                1.0,
                512,
                512,
                25,
                7.5,
                512,
                "euler",
                "png",
            )
            .await?;
    
        save_image(&controlnet_response.image, "controlnet_response.png")?;
    
        // Generate repainted image
        let repainted_image_response = client
            .generate_repainted_image(
                text_prompt,
                negative_prompt,
                &text_response.image,
                &image_response.image,
                Some(1.0),
                512,
                512,
                25,
                7.5,
                512,
                "euler",
                "png",
            )
            .await?;
    
        // Save repainted image to file
        save_image(&repainted_image_response.image, "repainted_image.png")?;
    
        // Generate edited image
        let edited_image_response = client
            .generate_edited_image(
                text_prompt,
                negative_prompt,
                &repainted_image_response.image,
                1.5,
                25,
                7.5,
                54,
                "ddim",
                "png",
            )
            .await?;
    
        // Save edited image to file
        save_image(&edited_image_response.image, "edited_image.png")?;
    
        Ok(())
    }

๐Ÿ“„ License

This project is licensed under the MIT License.

getimg's People

Contributors

wiseaidev avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.