This project demonstrates how to generate high-quality images from text prompts using the Stable Diffusion v1.5 model from RunwayML. Built with Python and the diffusers library, this pipeline makes it easy to create visually stunning images for creative exploration, concept art, and more.
- Overview
- Features
- Requirements
- Installation
- Usage
- Prompt Examples
- Output
- Model Information
- How It Works
- Negative Prompts
- Contributing
- License
Stable Diffusion is a state-of-the-art text-to-image model that transforms descriptive prompts into detailed images with artful precision. This project provides an accessible, GPU-accelerated pipeline to turn your ideas into visual content using the Stable Diffusion v1.5 model hosted on RunwayML.
- Text-to-Image Generation: Create images from detailed text prompts.
- Negative Prompts: Improve quality by excluding unwanted elements.
- Customizable Outputs: Save your creations locally in
.jpgformat. - GPU Acceleration: Enjoy faster generation times with CUDA-enabled GPUs.
- Intuitive Pipeline: Easy-to-use framework built with the
diffuserslibrary.
- Python: Version 3.7 or higher.
- Hardware: CUDA-enabled GPU with appropriate drivers.
- Dependencies:
diffuserstransformerstorch
git clone
cd Image_Generation_Using_Stable_DiffusionEnsure your system has a CUDA-enabled GPU and the necessary drivers, then install the Python packages using pip:
pip install diffusers transformers torchLaunch the Image_Generation_Stable_Diffusion_1_5_RunwayML.ipynb file in your preferred environment (Jupyter Notebook, VS Code, etc.).
Modify the prompt variable to describe the image you want to generate:
prompt = "A bustling futuristic city with flying cars and neon lights at night."Execute the notebook cells to generate your image. The resulting image will be saved as stable_diffusion_image_generation.jpg in the project directory. (You can change the filename in the notebook as needed.)
Experiment with different prompts to explore creative possibilities:
"A serene landscape with a crystal-clear lake surrounded by snow-capped mountains under a starry sky.""A bustling futuristic city with flying cars and neon lights at night.""A magical forest with glowing mushrooms and a fairy fluttering among the trees.""A cyberpunk-themed cityscape with neon lights and towering skyscrapers.""A steampunk airship soaring through the clouds during sunset."
The generated images will be saved in the project directory as stable_diffusion_image_generation.jpg. Modify the output filename in the notebook if you’d like to customize it.
This project uses the Stable Diffusion v1.5 model provided by RunwayML. For further details, check out the model’s Hugging Face page.
The model is loaded using the diffusers library and optimized for GPU acceleration with torch.float16 precision.
The user inputs a descriptive prompt (and an optional negative prompt) that guides the image generation process.
The model interprets the prompt and generates a corresponding image.
The final image is saved locally in the .jpg format for easy access and further use.
To refine image quality, you can use negative prompts to instruct the model to avoid specific elements. For example:
negative_prompt = """
simple background, duplicate, low quality, lowest quality,
bad anatomy, bad proportions, extra digits, lowres, username,
artist name, error, duplicate, watermark, signature, text,
extra digit, fewer digits, worst quality, jpeg artifacts, blurry
"""Contributions are welcome! If you have ideas or improvements, feel free to submit a pull request or open an issue. Your contributions help make this project even better.
This project is licensed under the MIT License.
Enjoy exploring the capabilities of Stable Diffusion v1.5! For further development, you might consider adding interactive web interfaces, real-time previews, or integrating more advanced prompt-engineering techniques to take your image generation to the next level.
This version ensures that everything is properly formatted for Markdown while improving readability and organization. Let me know if you need any adjustments!