А АSunday, 2 November 2025

JSON prompt as single workflow.

Hi all.

By the way, structured JSON prompts have another useful feature. Now we can put a whole series of actions(steps) into one prompt, making it like a single workflow.

For example, removing the background in one of my versions looks like this

1) Remove Background Ext:

{

  "Task": "Create a high-quality transparent image by removing the background from a source image.",

  "constraints": {

    "preserve_subject_details": true,

    "maintain_original_dimensions": true,

    "clean_edges": true

  },

  "steps": [

    {

      "step_id": 1,

      "name": "Generate High-Contrast Matte",

      "instructions": "Take the input image. Accurately segment the main subject(s) from the background. Replace the entire background with a solid, pure white color (hex #FFFFFF). The subject must be perfectly preserved with no alterations. The output image dimensions must be identical to the input image. Output this intermediate image as 'white_matte'."

    },

    {

      "step_id": 2,

      "name": "Create Transparency from Matte",

      "instructions": "Take the original input image and the 'white_matte' image from step 1. Use 'white_matte' as a pixel-perfect transparency mask for the original input image. Where 'white_matte' is pure white, the corresponding pixels of the original image must become fully transparent (alpha=0). Where 'white_matte' is not white, the original image pixels must be fully opaque (alpha=255). The anti-aliased (near-white) pixels along the subject's edge in 'white_matte' should be translated into corresponding levels of semi-transparency to ensure a smooth, clean edge. Output this as 'final_transparent_image'."

    }

  ],

  "Deliverables": {

    "transparent_png": "final_transparent_image"

  }

}

2) The same goes for creating a Loop Seamless Panorama:

{
  "Task": "Create a seamless horizontal panoramic loop from an image.",
  "constraints": {
    "no_distortion": true,
    "maintain_subject_integrity": true
  },
  "steps": [
    {
      "step_id": 1,
      "name": "Horizontal Expansion",
      "instructions": "Take the input image and expand it horizontally by approximately 2.5 times its original width. The generated content should naturally extend the background elements (like sky, landscape, etc.) without distorting the main subject. Output this as 'expanded_panorama'."
    },
    {
      "step_id": 2,
      "name": "Seamless Loop Adjustment",
      "instructions": "Take the 'expanded_panorama' image. Adjust the leftmost and rightmost sections of this image to ensure they seamlessly connect, creating a continuous horizontal loop without visible seams. Focus changes primarily on the edges to achieve the loop effect, preserving the central content as much as possible. Output this as 'final_seamless_loop'."
    }
  ],
  "Deliverables": {
    "final_seamless_loop_image": "final_seamless_loop"
  }
}

That's cool.

No comments:

Post a Comment

А что вы думаете по этому поводу?

Версия на печать

Популярное