# 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 `sevsd` directly from the source:
```bash
git clone https://github.com/leopedroso45/Stable-Diffusion-ImageGen
cd Stable-Diffusion-ImageGen
pip install .
````
## 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": "",
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": "",
"keywords": "image generation,stable diffusion,AI",
"author": "Leonardo Severo",
"author_email": "leopedroso45@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/fd/88/b7b92db60cf140358d1b2d8149aff37ceb2bf8124beec3ca1c3c6b2a516e/sevsd-0.1.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\nInstall `sevsd` directly from the source:\n\n```bash\ngit clone https://github.com/leopedroso45/Stable-Diffusion-ImageGen\ncd Stable-Diffusion-ImageGen\npip install .\n````\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": "",
"summary": "A Python package to make Stable Diffusion Image Generation ridiculously easy",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/leopedroso45/Stable-Diffusion-ImageGen"
},
"split_keywords": [
"image generation",
"stable diffusion",
"ai"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "77f4177f1f71cefcd34922be34a326a44ed2dcf6dfbda56dd896bd4a2c744df6",
"md5": "2d165794475596dfdfeff8f17c5ddc44",
"sha256": "0786fb276fb197fcd2e80cd6cea6736039323fe1a9f9d2ad48e5934905e4d5d6"
},
"downloads": -1,
"filename": "sevsd-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2d165794475596dfdfeff8f17c5ddc44",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 9324,
"upload_time": "2024-01-02T21:57:16",
"upload_time_iso_8601": "2024-01-02T21:57:16.044656Z",
"url": "https://files.pythonhosted.org/packages/77/f4/177f1f71cefcd34922be34a326a44ed2dcf6dfbda56dd896bd4a2c744df6/sevsd-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fd88b7b92db60cf140358d1b2d8149aff37ceb2bf8124beec3ca1c3c6b2a516e",
"md5": "6c4c877e57e4271f5efb0db1adf8ecc9",
"sha256": "0add24003aeefd59a57759b3b0c2b43dec3f0256c3fb86cc8a20fa144547fdfa"
},
"downloads": -1,
"filename": "sevsd-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "6c4c877e57e4271f5efb0db1adf8ecc9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 10663,
"upload_time": "2024-01-02T21:57:18",
"upload_time_iso_8601": "2024-01-02T21:57:18.654717Z",
"url": "https://files.pythonhosted.org/packages/fd/88/b7b92db60cf140358d1b2d8149aff37ceb2bf8124beec3ca1c3c6b2a516e/sevsd-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-02 21:57:18",
"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": []
}
],
"lcname": "sevsd"
}