Skip to main content

A tool for easy use of stable diffusion

Project description

stablepy

Description:

The goal of this project is to make Stable Diffusion more accessible, simple and easy-to-use with python. Stablepy is constructed on top of the Diffusers library

Usage:

To use the project, simply create a new instance of the Model_Diffusers class. This class takes several arguments, including the path to the Stable Diffusion model file and the task name.

Once you have created a new instance of the Model_Diffusers class, you can call the model() method to generate an image. The model() method takes several arguments, including the prompt, the number of steps, the guidance scale, the sampler, the image width, the image height, the path to the upscaler model (if using), etc.

Demo:

See stablepy_demo.ipynb

Open In Colab

Examples:

The following code examples show how to use the project to generate a text-to-image and an ControlNet diffusion:

from stablepy import Model_Diffusers

# Generate a text-to-image diffusion
model = Model_Diffusers(
    base_model_id='./models/toonyou_beta6.safetensors',
    task_name= 'txt2img',
)

image, path_image = model(
    prompt='highly detailed portrait of an underwater city, with towering spires and domes rising up from the ocean floor',
    num_steps = 30,
    guidance_scale = 7.5,
    sampler = "DPM++ 2M",
    img_width = 512,
    img_height = 1024,
    upscaler_model_path = "./upscaler/RealESRGAN_x4plus_anime_6B.pth",
    upscaler_increases_size = 1.5,
)

image[0]

Multiple LoRAs can also be used, as well as optimizations to the generation such as FreeU.

from stablepy import Model_Diffusers

# Generate an ControlNet diffusion
model = Model_Diffusers(
    base_model_id='./models/toonyou_beta6.safetensors',
    task_name= 'canny',
)

images, path_images = model(
    prompt='highly detailed portrait of an underwater city, with towering spires and domes rising up from the ocean floor',
    num_steps = 30,
    image_resolution = 768,
    guidance_scale = 7.5,
    seed = 567,
    FreeU = True,
    lora_A = "./loras/lora14552.safetensors",
    lora_scale_A = 0.8,
    lora_B = "./loras/example_lora3.safetensors",
    lora_scale_B = 0.5,
    image = "./examples/image001.png",
)

images[1]

Documentation:

In process

Contributing:

We welcome contributions to the project. If you have any suggestions or bug fixes, please feel free to open an issue or submit a pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stablepy-0.3.0.tar.gz (51.4 kB view details)

Uploaded Source

Built Distribution

stablepy-0.3.0-py3-none-any.whl (55.0 kB view details)

Uploaded Python 3

File details

Details for the file stablepy-0.3.0.tar.gz.

File metadata

  • Download URL: stablepy-0.3.0.tar.gz
  • Upload date:
  • Size: 51.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.8 Linux/6.2.0-1016-azure

File hashes

Hashes for stablepy-0.3.0.tar.gz
Algorithm Hash digest
SHA256 8f8c2a2bc579346b15b4c73e9951eb79ff3a6da0d86d002057f5c3d6c6882326
MD5 44459c79ccc87323c133dedea9ec8252
BLAKE2b-256 45e6223123bcce4a3ec01a714258081622458fc1a8dfa07bc06812e3d0c50521

See more details on using hashes here.

File details

Details for the file stablepy-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: stablepy-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 55.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.8 Linux/6.2.0-1016-azure

File hashes

Hashes for stablepy-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7632edbeea3d120fe3a7abae8837b56abf8683cadb6d231078c52066477da10d
MD5 6e7a501f15540e0f3f1bb4571a9045ef
BLAKE2b-256 edc405637fdb2c553fd32f20354d785fe2d738fde91b9bef98e643c37e423c0d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page