POST
javascript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 const axios = require('axios'); const fs = require('fs'); const path = require('path'); async function toB64(imgPath) { const data = fs.readFileSync(path.resolve(imgPath)); return Buffer.from(data).toString('base64'); } const api_key = "YOUR API-KEY"; const url = "https://api.segmind.com/v1/sd3-med-canny"; const data = { "prompt": "Anime style illustration of a girl wearing a suit. A moon in sky. In the background we see a big rain approaching.", "negative_prompt": "low quality,less details", "image": toB64('https://segmind-sd-models.s3.amazonaws.com/display_images/sd3m-controlnet/sd3-canny-ip.jpg'), "num_inference_steps": 20, "guidance_scale": 7, "seed": 698845, "samples": 1, "strength": 0.8, "sampler": "dpmpp_2m", "scheduler": "sgm_uniform", "base64": false }; (async function() { try { const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } }); console.log(response.data); } catch (error) { console.error('Error:', error.response.data); } })();
RESPONSE
image/jpeg
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing

Attributes


promptstr *

Text prompt for image generation


negative_promptstr ( default: low quality,less details )

Negative text prompt to avoid certain qualities


imageimage *

Input image


num_inference_stepsint ( default: 20 )

Number of inference steps for image generation

min : 1,

max : 100


guidance_scalefloat ( default: 7 )

Guidance scale for image generation

min : 1,

max : 20


seedint ( default: 698845 )

Seed for random number generation


samplesint ( default: 1 )

Number of samples to generate


strengthfloat ( default: 0.8 )

Strength of the image transformation

min : 0,

max : 1


samplerenum:str ( default: dpmpp_2m )

Sampler for the image generation process

Allowed values:


schedulerenum:str ( default: sgm_uniform )

Scheduler for the image generation process

Allowed values:


base64bool ( default: 1 )

Base64 encoding of the output image

To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.

Stable Diffusion 3 (SD3) Medium Canny ControlNet

Stable Diffusion 3 (SD3) Medium Canny ControlNet generates high-quality images based on textual prompts and input images. It utilizes Canny edge detection to provide fine-grained control over the generated outputs. SD3 ControlNet enhances image coherence and detail, making it a powerful tool for various image generation tasks.

How to Use the Model?

  1. Input Prompts: Provide a textual description of the desired image in the "Prompt" field.

  2. Input Image: Optionally, upload an image to guide the generation process.

  3. Negative Prompts: Indicate elements to exclude from the generation.

  4. Inference Steps: Set the number of steps for the model to refine the image. More steps typically result in higher quality.

  5. Strength: Use this to blend the input image with the generated output. Values close to 1 emphasize the input image more.

  6. Seed: Define a seed value for reproducibility. Randomly generate seeds if consistency is not required.

  7. Guidance Scale: Adjusts how closely the generated image follows the prompt. Higher values ensure the image aligns closely with the prompt.

How to Fine-Tune Outputs?

Fine-tuning the outputs can be achieved by adjusting several parameters:

  1. Inference Steps: Increasing the number of steps (e.g., from 20 to 50) can generate finer details but at the cost of longer processing times.

  2. Strength: Adjust the strength to control the influence of the input image. For minor adjustments, vary between 0.6 to 0.9. Lower values provide more creative freedom to the model.

  3. Guidance Scale: Typically between 7 and 15. Use higher values for strict adherence to prompts and lower values for more abstract results.

  4. Sampler: Different samplers (e.g., ddim, p_sampler) can affect the generation style and speed. Experiment with these to find the optimal balance for your use case.

Use Cases

SD3 Medium Canny ControlNet is versatile and can be applied to numerous scenarios:

  • Artistic Image Creation: Generate unique artwork based on textual prompts and rough sketches.

  • Design Prototyping: Quickly produce visual prototypes for product designs.

  • Story Illustration: Create coherent images to accompany literary descriptions.

  • Advertising: Generate tailored visuals for marketing materials.