This Python script demonstrates how to use the MMagic API to generate stunning images from text prompts using the powerful Stable Diffusion model. Simply provide a text prompt, and the script will create an image that brings your ideas to life! 🌟
git clone https://github.com/adrienckr/stablediff-mmagic.git
Before you get started, make sure you have the following dependencies installed:
- Python 3.8 (or a compatible version) 🐍
- Miniconda ⚙️
Follow these simple steps to set up your environment for using the MMagic Stable Diffusion model:
-
Install Miniconda on your system if you haven't already.
-
Create a Conda environment and activate it using the following commands:
conda create --name mmagic python=3.8 -y conda activate mmagic
-
Check your CUDA version by running the command:
nvcc --version
-
Install PyTorch by referring to the official PyTorch documentation. Select the appropriate configuration based on your system and follow the installation instructions.
-
Install the
MMCV
library usingMIM
, a package manager for AI and machine learning dependencies. Run the following commands:pip install -U openmim mim install 'mmcv>=2.0.0'
-
Install
mmengine
from the GitHub repository:pip install git+https://github.com/open-mmlab/mmengine.git
-
Install the
mmagic
toolbox in editable mode using the following command:git clone https://github.com/open-mmlab/mmagic.git cd mmagic pip3 install -e . -v
The
-e .
flag is used to install the Python package in editable mode, meaning that any changes made to the source code will be reflected in the installed package. -
Additionally, install
accelerate
for faster and less memory-intensive model loading:pip install accelerate
-
Run the script:
python app.py
-
You will be prompted to enter your text prompt. Type your desired prompt and press Enter.
-
**The script will generate an image based on your text prompt and save it to the
output
directory assd_res.png
. 🖼️
Now you're ready to create amazing images from your text prompts with MMagic's Stable Diffusion model! 🎨✨