Stable Diffusion Commands

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > SD - Stable Diffusion AI > SDL. - Stable Diffusion Local System > ! SDL - TXT2IMG >

Stable Diffusion Commands

SDL.Analyze

Previous Top Next


MiniRobotLanguage (MRL)

 

SDL.Analyze

Analyze and extract data from JSON string

 

Sampler_0031_Steps_140_SetSteps

Image generated with SDL. - Command.

 

Intention

 

The SDL.Analyze command is a sophisticated tool designed to process and analyze a given JSON string that was sent from your local "Automatic1111" Stable Diffusion Task.

The function not only examines the JSON but also extracts specific data, populating predefined variables for subsequent use.
Generally you do not need this command normally, as this is all done transparently using the SDL.Generate Picture to File Command.

This Command is therefore for special usage, for example if you want to use the Base64-Encoded Pictures to upload them to a Server for "Image to Image".

 
Upon successful analysis of the provided JSON string, specific data is extracted and stored into predefined variables:

AIO_Choices: Contains the number of choices/images present in the JSON.

AIO_Images(): An array storing the images retrieved from the JSON. The size of this array is determined by AIO_Choices.

InfoString: Contains the "info" value extracted from the JSON.

 

You can read these Variables as follows:

 

' Get AIO_Choices
AIC.Get Several|6|$$ANZ

' Get InfoString
AIC.Get Several|7|$$RET

' P1 - Nr. of Image 0.based, $$RET Variable that 
' will contain the Image Data in Base64-Format, needs to be decoded 

FOR.$$LOP|0|($$ANZ-1)

  SDL.Get Image|$$LOP|$$RET
  AIC.decode from Base64|$$RET|$$PIC

  ' Picture is now in $$PIC ready to be saved as "PNG"-File. 

  SDL.Copy Var to File|$$PIC|Image_?.png

NEX.

 

Error Handling

The command has built-in error handling that provides detailed error messages for a range of scenarios:

 

1.If the JSON doesn't contain an expected structure.

2.If there are issues extracting images or the 'info' value.

3.If the provided input is not a valid JSON.

4.If specific JSON elements are missing.

These error messages are particularly useful for understanding issues related to invalid input or unexpected content structures.

 

Examples

Analyze a JSON string and don't save the result:

 
SDL.Analyze|$$JSO

 

Analyze a JSON string and save the result to $$RET

SDL.Analyze||$$RET

 

Get the JSON from the internal SD_Return variable for analysis and save the result to TOS:

SDL.Analyze

 

The JSON String

The JSON String that is returned from the Local Stable Diffusion looks like this. Depending on the number of returned Images, in the Images Array.

 
{  "images": [

    "string"

  ],

  "parameters": {},

  "info": "string" 

}

 

 

Syntax

 

 

SDL.Analyze[|P1][|P2]

 

 

Parameter Explanation

 

P1 - (optional) Is the complete JSON Data as it is returned from the Server. You can leave that empty then the Command will take it
                                    from the last Server-Answer which is in the internal variable SD_Return.

P2 - (optional) Is the Variable that will receive a 0 or 1 to indicate if the process was successful. The extracted data is been placed in internal Register-Variables.

Upon successful analysis of the provided JSON string, specific data is extracted and stored into predefined variables:

AIO_Choices: Contains the number of choices/images present in the JSON.

AIO_Images(): An array storing the images retrieved from the JSON. The size of this array is determined by AIO_Choices.

InfoString: Contains the "info" value extracted from the JSON.

 

 

 

Example

 

'***********************************

' SDL.-Sample

'***********************************

$$PRO=Bio Food, natural women, meditating on a rainbow

$$NEG=ugly,comic,unrealistic,fat,unhealty,malformed faces

 

SDL.SetSteps|10 

SDL.Set_Sampler|3

SDL.Get Several|4|$$RET

DBP. Sampler=3 ($$RET)

SDL.Set Model Free|dreamlike-photoreal-2.0.safetensors

SDL.Set Extra Parameter|"restore_faces": true

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

SDL.gtv|$$PRO|$$NEG|$$RES

SDL.Analyze

SDL.Copy Image to File|0|?exeloc\CTF_Image_?.png|1|1

DMP.6

MBX.!

ENR.

 

 

 

 

 

Remarks

 

 This is an Command for special use and my not be needed for daily use.

 

 

Limitations:

 

-

 

 

See also:

 

    1.6.1. Program Flow Control

    ! Smart Package Robot 's Parallel Robot Operations

    1.5. Features and Hints