StableDiffusion - Generating AI Images with Stable Diffusion API
StableDiffusion for Nuke is a simple Nuke script that allows you to generate AI images using the stable diffusion API. This script is easy to use and can be integrated into your Nuke workflow seamlessly.
Getting Started
Installing Python and Necessary Modules
- Visit the official Python website and download the latest version of Python: https://www.python.org/downloads/
- Run the Python installer and follow the installation wizard to install Python on your system. Remember to select the option to add Python to your system PATH during installation.
- Open a command prompt or terminal and install the Requests module with the following command:
pip install requests
- Wait for the installation to complete.
- To be able to use the Animation SDK we need to install the
pip install stability_sdk
- Wait for the installation to complete.
Adding the Python Path to init.py file
The init.py file is located under the path C:\Users\{USER}\.nuke
, where {USER}
is your Windows username.
-
Open the file called init.py
in a text editor.
-
Add the following line to the init.py
file, replacing the path with the path to your Python executable. For example:
nuke.pluginAddPath("C:/Users/{USER}/AppData/Local/Programs/Python/Python311/Lib/site-packages")
-
Save the init.py
file.
-
Close and reopen Nuke for the changes to take effect.
Setting Up Stable Diffusion API
Before you can start using StableDiffusion, you need to set up the stable diffusion API.
- Sign in to Dream Studio (you'll need to create an account if you haven't done so already).
- Navigate to your account settings and find the API credentials section.
- Generate a new API key and make sure to keep it safe - you'll need it to use StableDiffusion.
More info Platform (stability.ai)
Using StableDiffusion
Once you have your API key, you can start using StableDiffusion in your Nuke workflow. Here's how to do it:
- Copy and paste the code into Nuke Script Editor and execute the code. This will create a new node called ‘Stability’ in the Node Graph
- A node called ‘Stability’ will appear in your Node Graph. Double-click on the node to open it.
- Paste your stable diffusion API key into the "API Key" field on the "Account" tab.
- Save it as a Toolset for easy access.
Saving StableDiffusion as a Toolset
If you plan on using StableDiffusion frequently, you can save it as a toolset for easy access from your toolbar:
- Right-click on the StableDiffusion node and select "Toolset" and "Create".
- Enter a name for the toolset and click "OK".
- The toolset will now be accessible from your toolbar. To use it, simply press 'Tab' and type the name.
Disclaimer
This project is a fun experiment and is not intended for production use. It may contain bugs and errors. Please use it with caution and at your own risk.