Create Custom Images Effortlessly with Mukbang's Inpainting Action

27 Apr 2025
Create Custom Images Effortlessly with Mukbang's Inpainting Action

In the ever-evolving world of digital content creation, the ability to generate unique and visually appealing images is invaluable. Mukbang offers a powerful Cognitive Action that allows developers to create images using intelligent inpainting techniques. This action not only streamlines the image generation process but also provides the flexibility to customize dimensions, aspect ratios, and model configurations. By harnessing this capability, developers can enhance their applications with unique visuals that resonate with their audience.

Common use cases for the Mukbang inpainting action include generating artwork for blogs, social media posts, or marketing materials. It can also be utilized in the gaming industry for creating character designs or in educational platforms for illustrative content. The ability to specify detailed prompts and parameters allows developers to tailor images to fit specific themes or narratives, making it an essential tool for any creative project.

Before diving into the integration, ensure you have a Cognitive Actions API key and a basic understanding of making API calls to leverage the full potential of Mukbang's capabilities.

Generate Image with Inpainting

The Generate Image with Inpainting action empowers developers to create customized images through an intelligent inpainting process. This action addresses the need for tailored visuals by allowing users to specify various attributes, including dimensions and styles, ensuring that the generated images meet specific requirements.

Input Requirements

To invoke this action, developers must provide a structured input, which includes:

  • Prompt: A descriptive text guiding the image generation (e.g., "an ECAL student eating noodles in the style of MKB").
  • Image and Mask: Optional URIs for the input image and mask, allowing for inpainting or image-to-image generation.
  • Dimensions: Customizable width and height in pixels, applicable when a custom aspect ratio is selected.
  • Model Configuration: Options for inference models, guidance scale, and output quality.

Expected Output

The output of this action is a URI pointing to the generated image based on the provided specifications. The image will reflect the input prompt and other parameters, delivering a unique visual asset.

Use Cases for this Specific Action

This action is particularly beneficial for:

  • Content Creators: Generate bespoke images for articles, enhancing visual engagement.
  • Marketing Teams: Create tailored graphics for campaigns that align with brand messaging.
  • Game Developers: Design characters and environments that fit specific artistic styles or themes.
  • Educators: Produce illustrative content for teaching materials that require specific visual contexts.
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 = "107f47ed-c173-4108-a786-e8f45c8e8db2" # 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 = {
  "width": 1440,
  "height": 1440,
  "prompt": "an ECAL student eating noodles in the style of MKB",
  "loraScale": 1.19,
  "numOutputs": 1,
  "guidanceScale": 3.5,
  "outputQuality": 100,
  "extraLoraScale": 1,
  "inferenceModel": "dev",
  "promptStrength": 0.8,
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "png",
  "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

The Mukbang inpainting action offers developers an efficient way to generate customized images that cater to a variety of needs. With its flexibility in dimensions, aspect ratios, and model configurations, it stands out as a versatile tool for any creative project. By integrating this action, developers can enhance their applications with visually appealing content that captures attention and communicates effectively.

As you explore the capabilities of Mukbang, consider how this action can elevate your projects and engage your audience in new and exciting ways. Start experimenting with the parameters and unleash your creativity!