Stable Diffusion Commands

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > SD - Stable Diffusion AI >

Stable Diffusion Commands

How to use Stable Diffusion with the Smart Package Robot

Previous Top Next


MiniRobotLanguage (MRL)

 

How to use Stable Diffusion with the SPR, Part I: SDL.

Here is a first Script you can run to get started

 

Boxen_anime_0001_1

You can generate all sorts of pictures using SDL. on your local computer.

 

The Smart Package Robot supports 2 versions of Stable Diffusion:

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.

 

What are the differences?

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.

 

Our first Script using SDL.

Lets start with SDL. (Local Stable Diffusion). I assume that you have installed it on your computer and that it works from the WEB-GUI.

I also assume that you have added the --api Parameter to the batch-file as described in the Installation chapter.

 

You need the Stable Diffusion Server to be running:
clip0764

 

You do NOT need the WEB-UI to be running:
clip0765

 

 

Now copy this Script below and run it.

 

' Here the propt does not have weights, also note that local version is uncesored

$$CON=croatian

$$PRO=sexy $$CON girl,rainbow colored hair,mountain and adria background,fotography

$$NEG=b/w,old(.5),fat(.3).Twins,twice,two

SDL.Set Size free|512|512

 

' We choose 50 Steps

SDL.SetSteps|50

$$FIL=?path\Opa_?.jpg

$$FIN=1024

$$COL=3

$$ROW=2

 

' We make 4 Pictures in one Run and we restore the faces.

$$EXT="save_images": true,

$$EXT+"batch_size": $$ROW, 

$$EXT+"n_iter": $$COL,

' Restore Faces using AI

$$EXT+"restore faces": true,

' Images im Default path von SD speichern

$$EXT+"save_images": true,

SDL.Set Extra Parameter|$$EXT

SDL.gtf|$$PRO|$$FIL|$$NEG|7

SDL.Set Scale|25

POP.$$PAT

POP.$$SUC

IVV.$$SUC=1

  ANA.load|0|$$PAT

  CAL.$$FIX=(($$FIN/$$ROW)*$$COL)  

  ANA.Resizeto|0|1|$$FIX|$$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=550

ANA.PrintAt|$$IMR|$$TXT|$$COA|$$BGC|$$XPA|$$YPA|24

ANA.PrintAt|$$IMR|$$TXT|$$COB|$$BGC|($$XPA+1)|($$YPA+2)|24

END%

  

 

ENR.

'===========================================================

 

 

 

Due to the Use of:

SDL.Set Extra Parameter|$$EXT

 

we will get a result of this picture through the API (as Output of the Smart Package Robot:

 

clip0770

Using SDL, the Script will in this Case only output a Picture that contain all the other pictures.
The full size single pictures will be stored in the original Stable DIffusion Output folder.

 

as we have defined:

$$ROW=2

$$COL=3

 

' and: (watch the "," at the end of each line!)

' we directly define JSON Content here, thats why the "," is needed.

 

$$EXT="save_images": true,

$$EXT+"batch_size": $$COL, 

$$EXT+"n_iter": $$ROW,

we will get 4 Rows and 5 Columns.

This is nearly the maximum SD will produce (5x5 may work as well).

 

All generated pictures will be stored in full size in the stable diffusion path:

' Last Folder is the Date

...\Stable_Diffusion\Automatic1111\stable-diffusion-webui\outputs\txt2img-images\2023-08-31

 

clip0771

Depending on Parameters. all generated pictures may be stored in the original Stable Diffusion Folder.

 

 

Now lets do some small changes so you can see what each Parameter will do.

 

$$CON=malaysian

$$PRO=sexy $$CON girl,rainbow colored hair,mountain and adria background,fotography

$$NEG=b/w,old(.5),fat(.3).Twins,twice,two

SDL.Set Size free|512|512

 

' We choose 50 Steps

SDL.SetSteps|50

$$FIL=?path\Pic_?.jpg

$$FIN=1024

$$COL=4

$$ROW=3

 

 

 

clip0772

Now we get 4 Columns and 3 Rows via API.

 

clip0773

   And all pictures in the original Stable Diffusion Folder.

 

Due to the internal working of SD this will not work in the same way with all possible numbers for $$ROW and $$COL.

 

Lets now just generate a Single picture.

 

We are going to change the following lines:

 

 

' Here the propt does not have weights, also note that local version is uncesored

$$CON=singapurian

$$PRO=sweet $$CON girl, riding a dragon,mountain and adria background,fotography

$$NEG=b/w,old(.5),fat(.3).Twins,twice,two

' Resolution which SD will render the pictures

SDL.Set Size free|512|512

 

' We choose 50 Steps

SDL.SetSteps|50

$$FIL=?path\Pic_?.jpg

' Resizing Resolution (512x512)

$$FIN=512

 

' We make 4 Pictures in one Run and we restore the faces.

$$EXT="save_images": true,

' Restore Faces using AI

$$EXT+"restore faces": true,

' Images im Default path von SD speichern

$$EXT+"save_images": false

SDL.Set Extra Parameter|$$EXT

SDL.gtf|$$PRO|$$FIL|$$NEG|7

SDL.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=850

ANA.PrintAt|$$IMR|$$TXT|$$COA|$$BGC|$$XPA|$$YPA|44

ANA.PrintAt|$$IMR|$$TXT|$$COB|$$BGC|($$XPA+1)|($$YPA+2)|44

END%

  

 

ENR.

'===========================================================

 

 

 

clip0774

Here we got only one picture via the API and we did not get any picture in the Original SD-Folder.

 

Special cases that occur when you use both Systems:

 

While this is a general rule, we have taken a lot of internal steps to make it as easy for you to switch between both systems at any time.

Therefore we have quite a lot of commands that are common to both systems.

These commands are most often available for SDO. as well as for SDL.

Some of them work on internal registers that are used by both systems. For example:

 

SDL.Set Positive Prompt

 

This will write the Prompt into an internal Register that is used by both Systems of Stable Diffusion.

 

Also there are Some commands that are shared between both systems, but use an own Set of registers, for example:

 

SDL.Prefix Positive Prompt

 

This command is available with SDO. and with SDL. but each of these uses an own register for the Prefix.