Create Stunning 3D Assets with the Hunyuan3D-2 Cognitive Actions

23 Apr 2025
Create Stunning 3D Assets with the Hunyuan3D-2 Cognitive Actions

In the realm of digital content creation, 3D assets play a pivotal role in enhancing user experiences. The Hunyuan3D-2 Cognitive Actions provide developers with powerful tools to generate high-resolution textured 3D assets from input images. By leveraging advanced diffusion models, these pre-built actions not only simplify the 3D asset creation process but also allow for customization through various settings. Let's dive into how you can integrate these actions into your applications.

Prerequisites

Before you start using the Hunyuan3D-2 Cognitive Actions, ensure you have the following:

  • API Key: You will need an API key to authenticate your requests to the Cognitive Actions platform. This key should be included in the headers of your requests.

Conceptually, the authentication might look something like this when making requests:

headers = {
    "Authorization": "Bearer YOUR_COGNITIVE_ACTIONS_API_KEY",
    "Content-Type": "application/json"
}

Cognitive Actions Overview

Generate High-Resolution Textured 3D Assets

This action allows you to create high-resolution textured 3D assets from a provided image. It is ideal for developers looking to automate the process of 3D generation while having control over various parameters for optimal output.

Category: 3D Reconstruction

Input

The input for this action is structured as follows:

  • seed (integer): Specifies a random seed used for the generation process, allowing for reproducibility. Default is 1234.
  • image (string): A URI pointing to the input image used for generating a 3D shape. The URI must be valid and accessible.
  • steps (integer): Determines the number of inference steps used in the generation process. Must be between 20 and 50. Default is 50.
  • guidanceScale (number): A scaling factor that influences the guidance used during generation. Must be between 1 and 20. Default is 5.5.
  • octreeResolution (integer): Defines the resolution of the octree used in mesh generation, affecting detail and performance. Options are 256, 384, or 512. Default is 512.
  • removeBackground (boolean): Indicates if the background should be removed from the input image. Default is true.

Example Input:

{
  "seed": 1234,
  "image": "https://replicate.delivery/pbxt/MVC2B2XKgv4X13qIpW6t2m59EVfY2CqaS9e2CSsWNHPJjQAd/image.png",
  "steps": 50,
  "guidanceScale": 5.5,
  "octreeResolution": 512,
  "removeBackground": true
}

Output

The action typically returns the following:

  • mesh (string): A URI link to the generated 3D mesh, which can be used to display or further manipulate the asset.

Example Output:

{
  "mesh": "https://assets.cognitiveactions.com/invocations/ce9f74cb-b277-47f6-9b70-b9ec081ae10c/69280699-7a65-409e-b25c-a17a078913c1.glb"
}

Conceptual Usage Example (Python)

Here’s how you might call the Generate High-Resolution Textured 3D Assets action using Python:

import requests
import json

# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint

action_id = "1be5d5a7-e60c-48cb-a641-682e825ae311"  # Action ID for Generate High-Resolution Textured 3D Assets

# Construct the input payload based on the action's requirements
payload = {
    "seed": 1234,
    "image": "https://replicate.delivery/pbxt/MVC2B2XKgv4X13qIpW6t2m59EVfY2CqaS9e2CSsWNHPJjQAd/image.png",
    "steps": 50,
    "guidanceScale": 5.5,
    "octreeResolution": 512,
    "removeBackground": true
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json={"action_id": action_id, "inputs": payload}  # Hypothetical structure
    )
    response.raise_for_status()  # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully:")
    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: {e.response.text}")

In this code snippet, the action_id and payload are crucial for making the request. The endpoint URL and request structure are illustrative and should be adjusted based on actual API documentation.

Conclusion

The Hunyuan3D-2 Cognitive Actions empower developers to create stunning high-resolution 3D assets quickly and efficiently. By leveraging customizable parameters, you can tailor the generation process to meet your project needs. Whether you're working on gaming, virtual reality, or architectural visualization, these actions provide a pathway to enrich your applications with dynamic 3D content. Start experimenting with the Cognitive Actions today and elevate your 3D asset creation to new heights!