# Easy Stable Diffusion Image Generation
![Build Status](https://github.com/leopedroso45/Stable-Diffusion-ImageGen/actions/workflows/python-package.yml/badge.svg)
[![codecov](https://codecov.io/gh/leopedroso45/Stable-Diffusion-ImageGen/branch/main/graph/badge.svg?token=YOUR_TOKEN)](https://codecov.io/gh/leopedroso45/Stable-Diffusion-ImageGen)
![License](https://img.shields.io/github/license/leopedroso45/Stable-Diffusion-ImageGen)
`sevsd` is a Python package specifically designed to make the process of generating images using Stable Diffusion models as simple as possible. The package enables image generation with just a single function call, greatly simplifying the integration of Stable Diffusion into various applications. Utilizing Hugging Face's `diffusers` library, `sevsd` provides an intuitive and flexible interface for generating images based on textual prompts. This makes it an ideal choice for building HTTP APIs, high-level services, or any application requiring AI-driven image generation.
## Features
- Simplified interface for Stable Diffusion image generation, enabling the creation of images with just a single function call.
- Easy integration of Stable Diffusion model into Python applications.
- Customizable image generation based on user-defined tasks and configurations.
- Batch processing capabilities for handling multiple tasks efficiently.
- Compatibility with CUDA-enabled GPUs and MPS (Apple's Metal Performance Shaders) for enhanced performance.
## Requirements
- Python 3.11+
- PyTorch
- Hugging Face `diffusers` library
- CUDA-compatible GPU (recommended for better performance)
## Installation
### Install from PyPI
You can install `sevsd` directly from PyPI. This is the recommended way to install the package as it will always provide you with the latest stable version:
```bash
pip install sevsd
```
### Install from Source
If you prefer to install `sevsd` from the source, for example, to get the latest changes that may not be released on PyPI yet, you can clone the repository and install it manually:
```bash
git clone https://github.com/leopedroso45/Stable-Diffusion-ImageGen
cd Stable-Diffusion-ImageGen
pip install .
```
Note: When installing from source, make sure you have the necessary build tools and dependencies installed on your system.
## Usage
Import and use `sevsd` in your Python project:
```python
from sevsd import do_work
# Define your models and jobs
models = [
{
"name": './model_cache/model1.safetensors',
"executor": {
"labels": [1],
"num_of_exec": 1,
"cfg_scale": 7,
"inference_steps": 100,
}
},
{
"name": './model_cache/model2.safetensors',
"executor": {
"labels": [2],
"num_of_exec": 2,
"cfg_scale": 6,
"inference_steps": 50,
}
},
]
jobs = [
{
"label": 1,
"prompt": 'A scenic landscape',
"negative_prompt": "blurred image, black and white, watermarked image",
},
{
"label": 2,
"prompt": 'A person wearing a mask',
"negative_prompt": 'deformed anatomy, hand-drawn image, blurred image',
},
]
do_work(models, jobs, './generated-images')
```
This example demonstrates a basic usage scenario. Customize the `models` and `jobs` as needed for your application.
## Components
- `setup_pipeline`: Prepares the Stable Diffusion pipeline with the specified model configuration.
- `process_task`: Processes individual tasks, generating and saving images based on job specifications.
- `generate_image`: Handles the image generation process for each job.
- `setup_device`: Sets up the computation device (GPU or CPU) for image generation.
- `check_os_path`: Ensures the output path exists or creates it.
- `check_cuda_and_clear_cache`: Manages GPU memory and cache for efficient processing.
- `do_work`: Central function to orchestrate the processing of jobs with corresponding models.
## Customization
You can customize the image generation process by adjusting the `models` and `jobs` lists. Define different prompts, model paths, execution parameters, and more to cater to diverse image styles and requirements.
## Note
- Ensure sufficient GPU memory if using CUDA.
- The package is optimized for flexible handling of various job and model configurations.
- For detailed examples and advanced usage, refer to the source code documentation.
## Contributing
Contributions to `sevsd` are welcome! Please refer to the repository's issues and pull requests for ongoing development.
## License
`sevsd` is licensed under the [MIT License](LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/leopedroso45/Stable-Diffusion-ImageGen",
"name": "sevsd",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "image generation, stable diffusion, AI",
"author": "Leonardo Severo",
"author_email": "leopedroso45@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/af/75/12b8e665c4ff1ac17e63fa25e113708eafd139e93845df851549c6e84da0/sevsd-0.5.0.tar.gz",
"platform": null,
"description": "# Easy Stable Diffusion Image Generation\n\n![Build Status](https://github.com/leopedroso45/Stable-Diffusion-ImageGen/actions/workflows/python-package.yml/badge.svg)\n[![codecov](https://codecov.io/gh/leopedroso45/Stable-Diffusion-ImageGen/branch/main/graph/badge.svg?token=YOUR_TOKEN)](https://codecov.io/gh/leopedroso45/Stable-Diffusion-ImageGen)\n![License](https://img.shields.io/github/license/leopedroso45/Stable-Diffusion-ImageGen)\n\n`sevsd` is a Python package specifically designed to make the process of generating images using Stable Diffusion models as simple as possible. The package enables image generation with just a single function call, greatly simplifying the integration of Stable Diffusion into various applications. Utilizing Hugging Face's `diffusers` library, `sevsd` provides an intuitive and flexible interface for generating images based on textual prompts. This makes it an ideal choice for building HTTP APIs, high-level services, or any application requiring AI-driven image generation.\n\n## Features\n\n- Simplified interface for Stable Diffusion image generation, enabling the creation of images with just a single function call.\n- Easy integration of Stable Diffusion model into Python applications.\n- Customizable image generation based on user-defined tasks and configurations.\n- Batch processing capabilities for handling multiple tasks efficiently.\n- Compatibility with CUDA-enabled GPUs and MPS (Apple's Metal Performance Shaders) for enhanced performance.\n\n## Requirements\n\n- Python 3.11+\n- PyTorch\n- Hugging Face `diffusers` library\n- CUDA-compatible GPU (recommended for better performance)\n\n## Installation\n\n### Install from PyPI\n\nYou can install `sevsd` directly from PyPI. This is the recommended way to install the package as it will always provide you with the latest stable version:\n\n```bash\npip install sevsd\n```\n\n### Install from Source\n\nIf you prefer to install `sevsd` from the source, for example, to get the latest changes that may not be released on PyPI yet, you can clone the repository and install it manually:\n\n```bash\ngit clone https://github.com/leopedroso45/Stable-Diffusion-ImageGen\ncd Stable-Diffusion-ImageGen\npip install .\n```\n\nNote: When installing from source, make sure you have the necessary build tools and dependencies installed on your system.\n\n## Usage\n\nImport and use `sevsd` in your Python project:\n\n```python\nfrom sevsd import do_work\n\n# Define your models and jobs\nmodels = [\n {\n \"name\": './model_cache/model1.safetensors',\n \"executor\": {\n \"labels\": [1],\n \"num_of_exec\": 1,\n \"cfg_scale\": 7,\n \"inference_steps\": 100,\n }\n },\n {\n \"name\": './model_cache/model2.safetensors',\n \"executor\": {\n \"labels\": [2],\n \"num_of_exec\": 2,\n \"cfg_scale\": 6,\n \"inference_steps\": 50,\n }\n },\n]\n\njobs = [\n {\n \"label\": 1,\n \"prompt\": 'A scenic landscape',\n \"negative_prompt\": \"blurred image, black and white, watermarked image\",\n },\n {\n \"label\": 2,\n \"prompt\": 'A person wearing a mask',\n \"negative_prompt\": 'deformed anatomy, hand-drawn image, blurred image',\n },\n]\n\ndo_work(models, jobs, './generated-images')\n```\n\nThis example demonstrates a basic usage scenario. Customize the `models` and `jobs` as needed for your application.\n\n## Components\n\n- `setup_pipeline`: Prepares the Stable Diffusion pipeline with the specified model configuration.\n- `process_task`: Processes individual tasks, generating and saving images based on job specifications.\n- `generate_image`: Handles the image generation process for each job.\n- `setup_device`: Sets up the computation device (GPU or CPU) for image generation.\n- `check_os_path`: Ensures the output path exists or creates it.\n- `check_cuda_and_clear_cache`: Manages GPU memory and cache for efficient processing.\n- `do_work`: Central function to orchestrate the processing of jobs with corresponding models.\n\n## Customization\n\nYou can customize the image generation process by adjusting the `models` and `jobs` lists. Define different prompts, model paths, execution parameters, and more to cater to diverse image styles and requirements.\n\n## Note\n\n- Ensure sufficient GPU memory if using CUDA.\n- The package is optimized for flexible handling of various job and model configurations.\n- For detailed examples and advanced usage, refer to the source code documentation.\n\n## Contributing\n\nContributions to `sevsd` are welcome! Please refer to the repository's issues and pull requests for ongoing development.\n\n## License\n\n`sevsd` is licensed under the [MIT License](LICENSE).\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python package to make Stable Diffusion Image Generation ridiculously easy",
"version": "0.5.0",
"project_urls": {
"Homepage": "https://github.com/leopedroso45/Stable-Diffusion-ImageGen"
},
"split_keywords": [
"image generation",
" stable diffusion",
" ai"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4b5b009f00bfdcb2ac087d3564e1c80761c20d8e545a59314ba245022fa84c7e",
"md5": "637256ed83bf5f30cf1915d105ce677a",
"sha256": "990df64bc32b22228d62e2b6a14e79035f1c27e7c2ff97d4b0aba263564ed423"
},
"downloads": -1,
"filename": "sevsd-0.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "637256ed83bf5f30cf1915d105ce677a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 10677,
"upload_time": "2024-07-01T00:36:37",
"upload_time_iso_8601": "2024-07-01T00:36:37.150365Z",
"url": "https://files.pythonhosted.org/packages/4b/5b/009f00bfdcb2ac087d3564e1c80761c20d8e545a59314ba245022fa84c7e/sevsd-0.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "af7512b8e665c4ff1ac17e63fa25e113708eafd139e93845df851549c6e84da0",
"md5": "b75497f9ea224e5921eb1783e7a01385",
"sha256": "a82663a14b218999a24a597038059882a6c7be98d8f5e9be4a4893c47649e2aa"
},
"downloads": -1,
"filename": "sevsd-0.5.0.tar.gz",
"has_sig": false,
"md5_digest": "b75497f9ea224e5921eb1783e7a01385",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 12820,
"upload_time": "2024-07-01T00:36:38",
"upload_time_iso_8601": "2024-07-01T00:36:38.490356Z",
"url": "https://files.pythonhosted.org/packages/af/75/12b8e665c4ff1ac17e63fa25e113708eafd139e93845df851549c6e84da0/sevsd-0.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-01 00:36:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "leopedroso45",
"github_project": "Stable-Diffusion-ImageGen",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"requirements": [
{
"name": "torch",
"specs": []
},
{
"name": "diffusers",
"specs": []
},
{
"name": "omegaconf",
"specs": []
},
{
"name": "transformers",
"specs": []
},
{
"name": "peft",
"specs": []
},
{
"name": "setuptools",
"specs": []
}
],
"lcname": "sevsd"
}