Git Product home page Git Product logo

stability-sdk's Introduction

stability-sdk

Open In Colab

Client implementations that interact with the Stability API.

Getting an API key

Follow the instructions on Platform to obtain an API key.

PyPI Package Installation

Install the PyPI package via:

pip install stability-sdk

Python Client

client.py is both a command line client and an API class that wraps the gRPC based API. To try the client:

  • Use Python venv: python3 -m venv pyenv
  • Set up in venv dependencies: pyenv/bin/pip3 install -e .
  • pyenv/bin/activate to use the venv.
  • Set the STABILITY_HOST environment variable. This is by default set to the production endpoint grpc.stability.ai:443.
  • Set the STABILITY_KEY environment variable.

Then to invoke:

python3 -m stability_sdk generate -W 512 -H 512 "A stunning house."

It will generate and put PNGs in your current directory.

To upscale: python3 -m stability_sdk upscale -i "/path/to/image.png"

SDK Usage

Be sure to check out Platform for comprehensive documentation on how to interact with our API.

Command line usage

usage: python -m stability_sdk generate [-h] [--height HEIGHT] [--width WIDTH] [--start_schedule START_SCHEDULE]
                 [--end_schedule END_SCHEDULE] [--cfg_scale CFG_SCALE] [--sampler SAMPLER]
                 [--steps STEPS] [--seed SEED] [--prefix PREFIX] [--engine ENGINE]
                 [--num_samples NUM_SAMPLES] [--artifact_types ARTIFACT_TYPES]
                 [--no-store] [--show] [--init_image INIT_IMAGE] [--mask_image MASK_IMAGE]
                 [prompt ...]

positional arguments:
  prompt

options:
  -h, --help            show this help message and exit
  --height HEIGHT, -H HEIGHT
                        [512] height of image
  --width WIDTH, -W WIDTH
                        [512] width of image
  --start_schedule START_SCHEDULE
                        [0.5] start schedule for init image (must be greater than 0, 1 is full strength
                        text prompt, no trace of image)
  --end_schedule END_SCHEDULE
                        [0.01] end schedule for init image
  --cfg_scale CFG_SCALE, -C CFG_SCALE
                        [7.0] CFG scale factor
  --sampler SAMPLER, -A SAMPLER
                        [auto-select] (ddim, plms, k_euler, k_euler_ancestral, k_heun, k_dpm_2,
                        k_dpm_2_ancestral, k_lms, k_dpmpp_2m, k_dpmpp_2s_ancestral)
  --steps STEPS, -s STEPS
                        [auto] number of steps
  --seed SEED, -S SEED  random seed to use
  --prefix PREFIX, -p PREFIX
                        output prefixes for artifacts
  --artifact_types ARTIFACT_TYPES, -t ARTIFACT_TYPES
                        filter artifacts by type (ARTIFACT_IMAGE, ARTIFACT_TEXT, ARTIFACT_CLASSIFICATIONS, etc)
  --no-store            do not write out artifacts
  --num_samples NUM_SAMPLES, -n NUM_SAMPLES
                        number of samples to generate
  --show                open artifacts using PIL
  --engine ENGINE, -e ENGINE
                        engine to use for inference
  --init_image INIT_IMAGE, -i INIT_IMAGE
                        Init image
  --mask_image MASK_IMAGE, -m MASK_IMAGE
                        Mask image

For upscale:

usage: client.py upscale
       [-h]
       --init_image INIT_IMAGE
       [--height HEIGHT] [--width WIDTH] [--prefix PREFIX] [--artifact_types ARTIFACT_TYPES]
       [--no-store] [--show] [--engine ENGINE]

options:
  -h, --help            show this help message and exit
  --init_image INIT_IMAGE, -i INIT_IMAGE
                        Init image
  --height HEIGHT, -H HEIGHT
                        height of upscaled image in pixels
  --width WIDTH, -W WIDTH
                        width of upscaled image in pixels
  --prefix PREFIX, -p PREFIX
                        output prefixes for artifacts
  --artifact_types ARTIFACT_TYPES, -t ARTIFACT_TYPES
                        filter artifacts by type (ARTIFACT_IMAGE, ARTIFACT_TEXT, ARTIFACT_CLASSIFICATIONS, etc)
  --no-store            do not write out artifacts
  --show                open artifacts using PIL
  --engine ENGINE, -e ENGINE
                        engine to use for upscale

Connecting to the API using languages other than Python

If a language you would like to connect to the API with is not currently documented on Platform you can use the following protobuf definition to compile stubs for your language:

Community-contributed clients

Stability API TOS

Usage of the Stability API falls under the STABILITY AI API Terms of Service.

stability-sdk's People

Contributors

chigozienri avatar christophervalore avatar dmarx avatar enzymezoo-code avatar frankwinfaber avatar github-actions[bot] avatar jacklangerman avatar jamalex avatar johnsabath avatar palp avatar pharmapsychotic avatar sayanarijit avatar wbrown avatar zippy731 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.