Create Stunning Images with Inpainting Using Northprint

25 Apr 2025
Create Stunning Images with Inpainting Using Northprint

Northprint is a powerful cognitive service designed to simplify the process of image generation through advanced inpainting techniques. With Northprint, developers can create images by specifying customizable parameters such as aspect ratio, dimensions, and output quality. This service not only accelerates the image creation process but also provides options for enhanced styles and concepts through additional LoRA weights.

Imagine needing to generate unique visuals for your applications or marketing campaigns without the hassle of manual design work. Northprint is perfect for use cases such as creating custom artwork, generating product images, or even enhancing existing images with new elements. Whether you’re building a creative application, an e-commerce platform, or simply looking to automate your design workflow, Northprint offers the tools necessary to produce high-quality images quickly and efficiently.

Prerequisites

Before you begin using Northprint, you will need a Cognitive Actions API key and a basic understanding of making API calls.

Generate Image With Inpainting

The "Generate Image With Inpainting" action allows you to create images using sophisticated inpainting methods. This action addresses the need for detailed and customizable image generation, enabling developers to craft visuals that meet specific requirements.

Input Requirements

To use this action, you must provide the following inputs:

  • prompt: A text description that guides the image generation (e.g., "a photo of snowing building in the style of north_print_vintage").
  • Additional parameters include:
    • image: (Optional) A URI of an input image for inpainting.
    • mask: (Optional) A URI of the mask image for inpainting mode.
    • model: Choose between "dev" for high detail or "schnell" for faster results.
    • aspectRatio, width, height: Define the dimensions of the output image.
    • numOutputs: Specify how many images to generate (1-4).
    • outputFormat: Choose the format for the output image (e.g., "webp", "jpg", "png").
    • Other parameters include guidanceScale, outputQuality, and LoRA weights for style enhancement.

Expected Output

The output of this action is a generated image based on the provided prompt and parameters. For example, an output might look like this:

  • https://assets.cognitiveactions.com/invocations/049374f9-3080-44b1-94a7-60a2b1c63e86/fa8c8c05-0678-4fbc-89fd-c52476f532e4.webp

Use Cases for this Specific Action

This action is ideal for various scenarios, including:

  • Art and Design: Generate unique artwork for digital galleries or personal projects.
  • E-Commerce: Create product images that stand out by inpainting existing images with new elements or styles.
  • Content Creation: Automate the generation of visuals for blogs, social media posts, or marketing materials.
  • Game Development: Design backgrounds or character assets by altering existing images creatively.
import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "9b773154-5076-43f4-b6dd-05d10426d54d" # Action ID for: Generate Image With Inpainting

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "image": "https://replicate.delivery/pbxt/M24FZOFP4Bpk7wZE8lhQCr7tViNQwVdsOpFd0LP3YSZUySIP/Screenshot_24-11-2024_234652_www.etsy.com.jpeg",
  "model": "dev",
  "prompt": "a photo of snowing building in the style of north_print_vintage",
  "loraScale": 1,
  "numOutputs": 1,
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 3.5,
  "outputQuality": 90,
  "extraLoraScale": 1,
  "promptStrength": 0.8,
  "numInferenceSteps": 28
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body (non-JSON): {e.response.text}")
    print("------------------------------------------------")

Conclusion

Northprint's "Generate Image With Inpainting" action empowers developers to produce stunning images with ease. By providing customizable parameters and leveraging advanced techniques, it simplifies the process of image creation while ensuring high-quality outputs. Whether you are enhancing existing visuals or generating new ones from scratch, Northprint can significantly streamline your workflow.

To get started, ensure you have your API key ready and explore the various input options to create the perfect image for your needs. Happy generating!