<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > SD - Stable Diffusion AI > Stable Diffusion Commands |
MiniRobotLanguage (MRL)
How to use Stable Diffusion with the SPR, Part I: SDO.
Here is a first Script you can run to get started
1. The Local Stable Diffusion, this needs the Automatic1111 to be installed and having the --api switch set in the "webui.bat" and you need a usable Graphics card with enough VRAM
2. The Stable Diffusion Online, this will need that you to get an API-Key to access the Cloud Services.
Depending on which service you want to use, you need to whether get the API-Key or install the Automatic1111 System on your computer or in your network.
In case you want to use Stabel Diffusion Online, the command of your choice is SDO.
If you decide the Stable Diffusion that runs Local - or in your Network, the Command of your choice is SDL.
1. Local Stable Diffusion is uncensored, so you can produce pictures of whatever you like, this includes naked pictures or pictures that are forbidden due to whatever ideologies.
2. Stable diffusion online is a cloud service and as such must uphold the rules for cloud services.
While it can also produce naked pictures in some cases (unless you add that to the negative prompt) from time to time,
it will send you an error message if you use words in your prompt that are in some censored lists. For example the word "sexy" is forbidden and will lead to an error message.
Just use the word "ugly" instead which is no problem.
3. For the local Stable diffusion, a Graphic card like an GTX 3080 is the Minimum and will possibly only work for Pictures not larger then 512x512.
To produce pictures of Size 1024x1024 possibly a larger VRAM of at least 12 GB may be needed.
4. For the Cloud service no Graphic card is needed as all calculations are done on the server. However each picture costs a very small amount of money,
its less then a Pence i think from what i have seen.
5. For SDL. you do not need any Key or authentication, and you can share your SPR-Scripts with anybody.
6.For SDO. you need an API-Key and its recommended that you use the SDO.Save Key Command to save it in your Script Folder so its accessible for the SPR.
Do not spread these Scripts as anybody could use your API-Key and generate Pictures on your cost.
If you compile EXE-Files its necessary to use the '#INC: Compiler-Statement to include the API-Key into the Executable.
You can also place it aside of the executable that will also work.
Lets start with SDO. (Stable Diffusion Online). I assume that you have got your API-Key for Stable Diffusion Online.
The first thin you need to do, is to save your API Key in your Script folder, using the SDO.Save Key Command.
We will start with the same Prompt like in Part I, SDL.
$$PRO=Sexy $$CON girl,rainbow colored hair,mountain and adria background,fotography
Doing so will deliver a Error-Message in return from the server.
Cloud services are bound to several rules and not all words are allowed here.
Using the same Prompt like with SDL. we will get this error message.
It shows that we have used forbiddden/censored words.
So lets change the words a bit:
SDO.SetKey|File
SDO.SetSize|512|512|stable-diffusion-v1-5
$$CON=croatian
$$PRO=beautiful $$CON girl,rainbow colored hair,mountain and adria background,fotography
$$NEG=ugly,comic,unrealistic,fat,unhealty,malformed faces
' The "?" will be replaced by a number
$$FIL=?exeloc\Sample_?.png
SDO.SetSteps|100
' We can produce up to 10 Pictures in one run!
SDO.Set Samples|4
POP.$$SAM
SDO.Set_Sampler|1
'SDL.Set Model Free|dreamlike-photoreal-2.0.safetensors
'SDL.Set Extra Parameter|"restore_faces": true
VAN.$$TIM=#dtime#
SDO.gtf|$$PRO|$$FIL|$$NEG|6
VAN.$$TIM=#dsince#|i
DBP. Set $$SAM Samples. In $$TIM Seconds.
DMP.6
MBX.!
ENR.
This time the result is as expected. We find the names of the generated pictures on the TOS.
Just one of the 4 generated Pictures using SDO.
Next lets take the same Script we used before for SDL. and change it to SDO.
Here is the complete Script:
SDO.SetKey|File
SDO.SetSize|512|512|stable-diffusion-v1-5
$$CON=Escimo
$$PRO=beautiful $$CON girl,rainbow colored hair,mountain and adria background,fotography
$$NEG=ugly,comic,unrealistic,fat,unhealty,malformed faces
SDO.Set Samples|1
' We choose 50 Steps
SDO.SetSteps|70
$$FIL=?path\SDO_Pics_?.jpg
$$FIN=512
SDO.gtf|$$PRO|$$FIL|$$NEG|7
SDO.Set Scale|15
POP.$$PAT
POP.$$SUC
IVV.$$SUC=1
ANA.load|0|$$PAT
ANA.Resizeto|0|1|$$FIN|$$FIN
%PicPrint SDL. generated.
ANA.show|1
ANA.Save|1|$$PAT
ELS.
SDL.Get Several|6|$$RET
DBP.$$RET
SDL.Show Error
MBT.No File generated.
EIF.
MBX.!
ENR.
' Macro to print into the Picture
: %PicPrint 1
$$IMR=1
$$TXT=§§§01
$$COA=&HFFFFFF
$$COB==&H0
$$BGC=-2
$$XPA=30
$$YPA=450
' We have changed some values here due to the Size of the picture
ANA.PrintAt|$$IMR|$$TXT|$$COA|$$BGC|$$XPA|$$YPA|24
ANA.PrintAt|$$IMR|$$TXT|$$COB|$$BGC|($$XPA+1)|($$YPA+2)|24
END%
ENR.
We had to remove this:
' Images im Default path von SD speichern
$$EXT+"save_images": false
$$EXT="save_images": true,
' Restore Faces using AI
$$EXT+"restore faces": true,
SDO.Set Extra Parameter|$$EXT
as this is not supported from SDO.
This is the picture we got using Style 14 (photographic). Here we used Style 7 - Fantasy Art