Package: sevsd
Easy Stable Diffusion Image Generationsevsdis 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'sdiffuserslibrary,sevsdprovides 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.FeaturesSimplified 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.RequirementsPython 3.11+PyTorchHugging FacediffuserslibraryCUDA-compatible GPU (recommended for better performance)InstallationInstallsevsddirectly from the source:gitclonehttps://github.com/leopedroso45/Stable-Diffusion-ImageGencdStable-Diffusion-ImageGen
pipinstall.UsageImport and usesevsdin your Python project:fromsevsdimportdo_work# Define your models and jobsmodels=[{"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 themodelsandjobsas needed for your application.Componentssetup_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.CustomizationYou can customize the image generation process by adjusting themodelsandjobslists. Define different prompts, model paths, execution parameters, and more to cater to diverse image styles and requirements.NoteEnsure 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.ContributingContributions tosevsdare welcome! Please refer to the repository's issues and pull requests for ongoing development.Licensesevsdis licensed under theMIT License.