A simple Python application that uses Stable Diffusion to modify images based on text prompts. This tool allows you to transform existing images using AI-generated modifications.
- Load images from URLs or local files
- Edit images using natural language prompts
- Save generated images
- Create side-by-side comparisons of original and edited images
- Python 3.8+
- CUDA-compatible GPU (recommended) for faster processing
- Required Python packages (see
requirements.txt)
- Clone this repository or download the source code
- Install the required dependencies:
pip install -r requirements.txtRun the application using:
python main.pyFollow the prompts in the terminal:
- Choose whether to use an image from a URL or a local file
- Provide the URL or file path
- Enter your modification prompt (e.g., "convert to oil painting", "make it winter themed")
- The application will generate and save:
- The modified image as
generated_image.png - A side-by-side comparison as
image_grid.png
- The modified image as
Do you want to use an image from URL or local file? (url/file): url
Enter image URL: https://example.com/image.jpg
Enter your modification prompt: convert to watercolor style
Generating image with prompt: convert to watercolor style
Image saved as generated_image.png
Grid saved as image_grid.png
Process completed successfully!
The application uses Hugging Face's Diffusers library and the Stable Diffusion image-to-image pipeline. It loads the pre-trained model, processes your input image with the given prompt, and generates a modified version while preserving the overall structure of the original image.
You can modify the code to:
- Use different Stable Diffusion models by changing the
model_nameparameter - Adjust image generation parameters
- Implement batch processing for multiple images