ImagePipeline Documentation

website·Indexed 32 days ago

https://docs.imagepipeline.io

API documentation for a suite of AI image generation tools and pipelines. Features optimized base models including Stable Diffusion 3.5, Stable Diffusion 1.5, and Flux-Schnell, as well as specialized pipelines for face control (Photomaker, Face Lock, Instamodel), fashion virtual try-on, and image manipulation tools like inpainting, relighting, and LoRA fine-tuning.

Tokens
23.7K
Snippets
118
Records
143
Agent score
55%

What's inside ImagePipeline

  1. Compare Stable Diffusion 1.5 and SDXL capabilities

    SDXL differs from Stable Diffusion 1.5 in several key architectural and performance areas:

    • Architecture: SDXL is a multi-stage pipeline model, whereas SD 1.5 is a single-stage model, allowing SDXL to generate more complex details.
    • Training: SDXL was trained on a larger dataset, resulting in better world understanding and more believable images.
    • Versatility: SDXL supports a wider variety of styles (realistic, cartoonish, abstract) and follows complex, detailed prompts more accurately than SD 1.5.
  2. Upload a model to Image Pipeline

    To upload a model (Checkpoint, LoRA, ControlNet, or Embedding) to Image Pipeline, send a POST request to the model load endpoint. Upon successful upload, you will receive a model_id which must be used when generating images.

    Requirements for Public Models:

    • Must be licensed for commercial use.
    • Must be correctly marked as NSFW (nudity/obscenity) or not.
    • Must credit the original uploader in the description.
    • Must include usage instructions in the description.
    • Note: Public models are subject to verification before appearing on the Models Page.
    # Endpoint: https://api.imagepipeline.io/load_model/v1/
    # Authorization: API-Key
  3. Check the status of an Upscale task

    When submitting an upscale request, the API returns a status field. Depending on the value, you should handle the response as follows:

    • SUCCESS: The response contains download_urls (up to 2 samples).
    • PENDING: The response contains an id. Use this ID to poll the status endpoint.
    • FAILURE: The response contains an error message.

    To poll for a pending task, perform a GET request to the status endpoint using the provided ID, passing the API-Key in the header.

    # GET request to check status
    GET https://api.imagepipeline.io/upscaler/v1/status/{{id}}
    Header: API-Key: Your API Key
  4. Example: Upload a Public LoRA model

    This example demonstrates how to upload a public LoRA model for SD 1.5, including a download URL from CivitAI and sample images.
    {
      "model_name": "Add-more-details",
      "model_url": "https://civitai.com/api/download/models/87153?type=Model&format=SafeTensor",
      "base_model": "sd1.5",
      "model_type": "lora",
      "description": "Developed for adding more details to SD 1.5 images. Tweak the lora weights between 0.5 to 1.",
      "sample_images": ["https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/c1697174-7c8d-4bde-b053-7b1ec0692b64/width=450/xyz_grid-0361-132340235-8k%20portrait%20of%20beautiful%20cyborg%20with%20brown%20hair,%20intricate,%20elegant,%20highly%20detailed,%20majestic,%20digital%20photography,%20art%20by%20artg_.jpeg"],
      "tags": "SD 1.5, LoRA",
      "nsfw": false,
      "revision": "fp16",
      "model_extension": "lora",
      "trigger_words": "",
      "visibility": "public"
    }
  5. Generate images using the optimized Stable Diffusion 1.5 model

    Use the /generate/v1 endpoint to create high-quality images using an optimized SD 1.5 base model. The API accepts a JSON payload containing a required prompt and optional style and control parameters.
    import requests
    import json
    
    url = "https://api.imagepipeline.io/generate/v1"
    headers = {
        "API-Key": "Your API Key"
    }
    data = {
        "prompt": "cat wizard, gandalf, lord of the rings, detailed, fantasy, cute, adorable, Pixar, Disney, 8k",
        "style" : "realistic_portrait"
    }
    
    response = requests.post(url, headers=headers, data=json.dumps(data))
    print(response.json())
  6. Use IP-Adapters with SDXL for face locking and image refinement

    IP-Adapters allow you to lock a specific face across different environments, fix deformities in hands or fingers, and add specific details to generated images. Currently, this feature only supports the foundation SDXL model. For face adapters, it is recommended to use a close-up image of the face as the input rather than a full-body shot.
  7. Check generation status and retrieve images

    The API response includes a status field. If the status is PENDING, the response will contain an id which must be used to poll the status endpoint to retrieve the final image URLs. If the status is SUCCESS, download_urls are provided immediately.

    Status Endpoint

    GET https://api.imagepipeline.io/sd/controlnet/v1/status/{{id}}

    Header: API-Key: Your API Key

  8. Generate images using ControlNet SD1.5

    ControlNet allows for conditional control over text-to-image generation by specifying constraints like composition or style. To use it, send a POST request to https://api.imagepipeline.io/sd/controlnet/v1 with your API key in the header. It is recommended to use negative prompts to remove potential artifacts introduced by ControlNets.
    import requests
    import json
    
    url = "https://api.imagepipeline.io/sd/controlnet/v1"
    headers = {
        "API-Key": "Your API Key"
    }
    data = {
      "prompt": "Snow White's face, best quality, extremely detailed",
      "negative_prompt": "monochrome, lowres, bad anatomy, worst quality, low quality",
      "model_id": "sd1.5",
      "controlnets": ["canny"],
      "init_images": ["https://cdn.pariscityvision.com/library/image/5449.jpg"],
      "controlnet_weights": [0.5],
      "starting_control_steps": [],
      "ending_control_steps": [],
      "num_inference_steps": 20,
      "samples": 1,
      "guidance_scale": 7.5,
      "height": 512,
      "width": 512,
      "safety_checker": false
    }
    
    response = requests.post(url, headers=headers, data=json.dumps(data))
    print(response.json())
  9. Change a person in an image using Model Switch

    The Model Switch API allows you to replace the human in a provided image with another person described via a text prompt. For best results, use simple prompts and specifically mention desired facial characteristics.
    # POST request to https://api.imagepipeline.io/modelswitch/v1
    # Header: API-Key: YOUR_API_KEY
    
    {
      "input_image": "https://f005.backblazeb2.com/file/imageai-model-images/lav-min.png",
      "prompt": "green eyed blonde woman, caucasian"
    }
  10. Use IP-Adapters with SD 1.5 for face locking and image refinement

    IP-Adapters allow you to fix deformities (hands, fingers, faces), lock a specific face for consistency across different environments, or add details to an image. They are compatible with all checkpoint models based on SD 1.5. For face adapters, it is recommended to use a cropped image of the face as the input rather than a full-body shot.
  11. Perform image inpainting with Stable Diffusion 1.5

    Inpainting allows you to restore missing parts of an image or add new elements by providing an initial image, a mask outlining the areas to be changed, and a text prompt describing the desired content. The API analyzes these inputs to generate a seamless blend of new content into the original image.
  12. Transform images using Stable Diffusion 1.5 img2img API

    The Stable Diffusion 1.5 image-to-image capability allows you to modify or transform existing images using text descriptions. To use this service, send a POST request to the https://api.imagepipeline.io/sd/image2image/v1 endpoint with your API key in the headers.
    import requests
    import json
    
    url = "https://api.imagepipeline.io/sd/image2image/v1"
    headers = {
        "API-Key": "Your API Key"
    }
    data = {
        "model_id":  "sd1.5",
        "prompt": "gingerbread house with fairy lights and realistic finish, 8k quality",
        "negative_prompt": "error, cropped, worst quality, low quality, duplicate, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, deformed, blurry, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck",
        "num_inference_steps": 30,
        "refiner": false,
        "samples": 1,
        "guidance_scale": 7.5,
        "width": 512,
        "height": 512,
        "init_image": "https://docs.imagepipeline.io/img/cottage.png",
        "seed": 12345,
        "scheduler": "UniPCMultistepScheduler",
        "safety_checker": true
    }
    
    response = requests.post(url, headers=headers, data=json.dumps(data))
    print(response.json())