stable-diffusion

Stable Diffusion, how to set a background text using the /sdapi/v1/txt2img


I have Stable Diffusion running in a VM in GCP. I want to generate a picture based on text but also have a specific word in the background. For example: "City skyline" as the picture and "New York" as a text in the background. I have only found solutions where you either add a picture with the background text or uses python to create pil images. Is there a way to send the background text as a parameter? I am creating a .NET service. The api for /sdapi/v1/txt2img is this:

    {
      "prompt": "City skyline",
      "negative_prompt": "",
      "styles": [
        "string"
      ],
      "seed": -1,
      "subseed": -1,
      "subseed_strength": 0,
      "seed_resize_from_h": -1,
      "seed_resize_from_w": -1,
      "sampler_name": "string",
      "batch_size": 1,
      "n_iter": 1,
      "steps": 50,
      "cfg_scale": 7,
      "width": 512,
      "height": 512,
      "restore_faces": true,
      "tiling": true,
      "do_not_save_samples": false,
      "do_not_save_grid": false,
      "eta": 0,
      "denoising_strength": 0,
      "s_min_uncond": 0,
      "s_churn": 0,
      "s_tmax": 0,
      "s_tmin": 0,
      "s_noise": 0,
      "override_settings": {},
      "override_settings_restore_afterwards": true,
      "refiner_checkpoint": "string",
      "refiner_switch_at": 0,
      "disable_extra_networks": false,
      "comments": {},
      "enable_hr": false,
      "firstphase_width": 0,
      "firstphase_height": 0,
      "hr_scale": 2,
      "hr_upscaler": "string",
      "hr_second_pass_steps": 0,
      "hr_resize_x": 0,
      "hr_resize_y": 0,
      "hr_checkpoint_name": "string",
      "hr_sampler_name": "string",
      "hr_prompt": "",
      "hr_negative_prompt": "",
      "sampler_index": "Euler",
      "script_name": "string",
      "script_args": [],
      "send_images": true,
      "save_images": false,
      "alwayson_scripts": {}
}

Solution

  • I realized you can not send this as an input. You have to create the text to an image and then apply the image.