Create Stunning Custom Images Effortlessly with Gotcha

26 Apr 2025
Create Stunning Custom Images Effortlessly with Gotcha

In today's digital landscape, the ability to generate customized images on demand is a game-changer for developers and designers alike. Gotcha offers a powerful set of Cognitive Actions that enable you to create unique and tailored images using advanced techniques like Hyper-SD, Instanx IP Adapter, Pulid, and Depth ControlNet. This service simplifies the image generation process, allowing you to focus on creativity and innovation without getting bogged down by technical complexities.

Imagine being able to seamlessly produce high-quality images that fit specific requirements—whether it's for marketing materials, social media posts, or product designs. With Gotcha, you can achieve this effortlessly, saving both time and resources. The intuitive input structure accommodates various parameters, ensuring that you can generate images that meet your exact specifications.

Prerequisites

To get started with Gotcha, you'll need a Cognitive Actions API key and a basic understanding of making API calls. This will allow you to access the powerful features and capabilities that Gotcha has to offer.

Generate Customized Images

The primary action within Gotcha is the Generate Customized Images action, designed to create bespoke images that resonate with your vision.

Purpose

This action allows you to create customized images using a combination of advanced image generation techniques. By leveraging face and depth control features, developers can generate images that are not only visually appealing but also tailored to specific narratives or themes.

Input Requirements

The action requires a structured input schema that includes:

  • prompt: A textual description of the desired image (e.g., "one girl and one boy, back to back").
  • seed: A random seed for reproducible results.
  • image: A URI of the input image for the IP Adapter.
  • aspectRatio: The desired aspect ratio for the output image (defaults to "1:1").
  • faceImage: A URI of the face image for Pulid processing.
  • controlImage: A URI for Depth ControlNet processing.
  • faceStrength: Controls the intensity of face image processing.
  • guidanceScale: Determines the weight of guidance in the diffusion process.
  • imageStrength: Affects the application of the IP Adapter effect.
  • outputFormat: Specifies the format of the output image (e.g., webp, jpg, png).
  • numberOfOutputs: Defines how many images to generate.
  • depthControlStrength: Adjusts the level of depth control.
  • numberOfInferenceSteps: Sets the number of steps for inference.

Expected Output

Upon successful execution, the action returns a URI for the generated image, allowing you to easily access and utilize the custom creation.

Use Cases for this Specific Action

  • Marketing Campaigns: Generate unique visuals that align with specific themes or products, enhancing the appeal of marketing materials.
  • Social Media Content: Create tailored images that capture attention and drive engagement on platforms like Instagram or Facebook.
  • Product Prototyping: Produce conceptual images that visualize product ideas before moving into the design phase.
  • Creative Projects: Empower artists and designers to explore new creative directions with customized imagery that reflects their vision.
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 = "0c21a941-b7c5-4bad-bada-0ef20a5e852e" # Action ID for: Generate Customized Images

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "seed": 0,
  "image": "https://replicate.delivery/pbxt/M2taCSgZyuzo9GSSi8JAtMG975BXwFk9IsTRyJdbxkOQd0l5/ref1.webp",
  "prompt": "one girl and one boy, back to back",
  "aspectRatio": "3:4",
  "outputFormat": "webp",
  "guidanceScale": 3.5,
  "imageStrength": 0.5,
  "outputQuality": 80,
  "numberOfOutputs": 1,
  "depthControlStrength": 0.7,
  "disableSafetyChecker": false,
  "numberOfInferenceSteps": 8
}

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

Gotcha's image generation capabilities provide developers with the tools they need to create stunning visuals quickly and efficiently. By understanding the input requirements and potential use cases, you can leverage this powerful action to enhance your creative projects and meet your business needs. As you explore the possibilities with Gotcha, consider how these customized images can elevate your work, streamline your processes, and open new avenues for creativity. Start integrating Gotcha today and unlock the full potential of customized image generation!