POST
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 36 37 38 39 40 41 42 43 import requests import base64 # Use this function to convert an image file from the filesystem to base64 def image_file_to_base64(image_path): with open(image_path, 'rb') as f: image_data = f.read() return base64.b64encode(image_data).decode('utf-8') # Use this function to fetch an image from a URL and convert it to base64 def image_url_to_base64(image_url): response = requests.get(image_url) image_data = response.content return base64.b64encode(image_data).decode('utf-8') api_key = "YOUR_API_KEY" url = "https://api.segmind.com/v1/flux-controlnet" # Request payload data = { "base64": False, "cn_stop": 0.5, "cn_strength": 0.4, "cn_type": "pose", "custom_height": 1024, "custom_width": 1024, "guidance": 3.5, "image": image_url_to_base64("https://segmind-sd-models.s3.amazonaws.com/display_images/model_1.png"), # Or use image_file_to_base64("IMAGE_PATH") "image_format": "jpeg", "prompt": "Young woman in leather jacket and black mini skirt, busy city street, bokeh background, Kodak film, sunglasses on head, high quality photo, photorealistic, sharp focus, vibrant colors, urban fashion, street style, natural lighting, 35mm lens", "quality": 95, "sampler": "euler", "samples": 1, "scheduler": "simple", "seed": 652889, "steps": 20, "use_input_img_dimension": True } headers = {'x-api-key': api_key} response = requests.post(url, json=data, headers=headers) print(response.content) # The response is the generated image
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


base64bool ( default: 1 )

Output as base64 encoded string


cn_stopfloat ( default: 0.5 )

ControlNet stop parameter

min : 0,

max : 1


cn_strengthfloat ( default: 0.45 )

ControlNet strength

min : 0,

max : 2


cn_typeenum:str ( default: pose )

ControlNet type

Allowed values:


custom_heightint ( default: 1024 )

Custom height for output image

min : 64,

max : 4096


custom_widthint ( default: 1024 )

Custom width for output image

min : 64,

max : 4096


guidancefloat ( default: 3.5 )

Guidance scale for the generation

min : 1,

max : 15


imageimage *

Input image


image_formatenum:str ( default: jpeg )

Output image format

Allowed values:


promptstr *

The prompt describing the image


qualityint ( default: 95 )

Image quality setting for output

min : 10,

max : 100


samplerenum:str *

Sampling method for image generation

Allowed values:


samplesint ( default: 1 )

Number of samples to generate

min : 1,

max : 4


schedulerenum:str *

Scheduler for image generation

Allowed values:


seedint *

Random seed for generation


stepsint ( default: 20 )

Number of steps for generating the image

min : 15,

max : 75


use_input_img_dimensionbool ( default: true )

Use input image dimensions for output image. Uncheck to specify custom height and custom width.

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.

Flux ControlNet

Flux ControlNet is a cutting-edge collection of models designed to enhance image generation tasks by integrating ControlNet with the Flux.1 model. Developed by Black Forest Labs, these models offer unparalleled control over the output, making them a game-changer in the field of AI-driven image generation.

Flux ControlNet allows for precise control over image composition by adding extra conditions to the diffusion models. This integration supports multiple models, including Canny, Pose, and Depth & Tile.

Flux ControlNet leverages the power of ControlNet to provide additional input conditions, such as edge maps and depth maps, to guide the image generation process. This allows for more detailed and accurate outputs, tailored to specific requirements.

  • Canny ControlNet: Utilizes edge detection to define the structure of the generated image.

  • Pose ControlNet: Utilizes detection and extraction of human pose keypoints from images.

  • Depth ControlNet: Uses depth maps to add a sense of three-dimensionality to the images

  • Tile Controlnet: Leverages tiling techniques which ensures the creation of coherent, large-scale images with exceptional detail and consistency

Use cases

  • Canny ControlNet isIdeal for generating comic book art with bold outlines and ink-like strokes, or highlighting building structures and edges in architectural visualizations.

  • Depth ControlNet is Well-suited for populating virtual reality environments with realistic textures or showcasing objects with accurate depth cues.

  • Openpose ControlNet is particularly useful for animating characters with precise poses in character animation or creating virtual fashion models for showcasing clothing in fashion design.

  • Tile ControlNet is Ideal for scenarios requiring expansive and detailed visual outputs.