Create Stunning 3D Assets with ndreca/hunyuan3d-2 Cognitive Actions

24 Apr 2025
Create Stunning 3D Assets with ndreca/hunyuan3d-2 Cognitive Actions

In today's digital landscape, generating high-quality 3D assets is essential for game development, virtual reality, and augmented reality applications. The ndreca/hunyuan3d-2 Cognitive Actions offer developers powerful tools to create high-resolution textured 3D assets directly from images. By leveraging advanced diffusion models, these actions allow for precise control over various generation parameters, making asset creation smoother and more efficient.

Prerequisites

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

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of JSON and RESTful API concepts.
  • A programming environment set up to make HTTP requests (Python, in this example).

To authenticate, you'll typically pass your API key in the request headers, ensuring secure access to the Cognitive Actions.

Cognitive Actions Overview

Generate High-Resolution Textured 3D Assets

The Generate High-Resolution Textured 3D Assets action utilizes diffusion models to transform input images into intricate 3D models. With adjustable parameters such as image source, guidance scale, and octree resolution, developers can control the output to meet their specific needs.

Input

The input for this action is structured as follows:

{
  "seed": 1234,
  "image": "https://replicate.delivery/pbxt/MVC2B2XKgv4X13qIpW6t2m59EVfY2CqaS9e2CSsWNHPJjQAd/image.png",
  "steps": 50,
  "guidanceScale": 5.5,
  "octreeResolution": 512,
  "removeBackground": true
}
  • seed (integer, default: 1234): A random seed for consistent generation.
  • image (string, URI): The URL of the input image used to generate the 3D shape.
  • steps (integer, default: 50): Number of inference steps (range: 20-50).
  • guidanceScale (number, default: 5.5): Controls guidance scale (range: 1-20).
  • octreeResolution (integer, default: 256): Resolution for mesh generation (options: 256, 384, 512).
  • removeBackground (boolean, default: true): Whether to remove the image background.

Output

The output of this action is a JSON object that typically includes:

{
  "mesh": "https://assets.cognitiveactions.com/invocations/876e72cd-768a-4a91-b286-6d8e7cff453a/623299a2-3679-4cfe-95d7-ff39963452a9.glb"
}
  • mesh (string): A URL pointing to the generated 3D mesh file in GLB format.

Conceptual Usage Example (Python)

Here's how you might invoke 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 = "594b598c-80a4-4082-8499-d4b3d34b0aae" # 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, replace the API key and endpoint with your actual values. The payload is constructed based on the input requirements of the action. The response from the API will provide you with the URL of the generated 3D mesh.

Conclusion

The ndreca/hunyuan3d-2 Cognitive Actions empower developers to effortlessly generate high-resolution textured 3D assets from images. With customizable parameters, you can fine-tune your outputs to suit various applications in gaming, VR, and AR. Explore the capabilities of these actions to enhance your projects and create stunning 3D visuals. Happy coding!