Create Stunning 3D Assets with Tencent's Hunyuan3D-2mv Cognitive Actions

21 Apr 2025
Create Stunning 3D Assets with Tencent's Hunyuan3D-2mv Cognitive Actions

In the world of 3D modeling, the ability to generate high-quality assets efficiently is paramount. The Tencent Hunyuan3D-2mv Cognitive Actions provide developers with powerful tools for generating textured 3D models from multiple image perspectives. By leveraging these pre-built actions, you can streamline your 3D asset creation process, enhance the realism of your applications, and save valuable development time.

Prerequisites

Before diving into the integration of these Cognitive Actions, ensure you have the following:

  • An API key for accessing the Tencent Cognitive Actions platform.
  • Basic understanding of JSON and how to make API calls.
  • Familiarity with Python for implementing the conceptual usage examples.

Authentication Concept

Generally, authentication involves passing the API key in the request headers. This ensures that your application is authorized to make calls to the Cognitive Actions API.

Cognitive Actions Overview

Generate 3D Models with Multiview Control

This action allows you to generate high-resolution textured 3D models by providing images from multiple angles. It fine-tunes the Hunyuan3D-2 model to create realistic assets that can be used in various applications, including gaming and VR.

Input

The input schema for this action requires several fields, with the front, back, left, and right images being mandatory for generating the 3D model.

  • Required Fields:
    • frontImage: URI of the front view image (mandatory).
    • backImage: URI of the back view image (required).
    • leftImage: URI of the left view image (required).
    • rightImage: URI of the right view image (required).
  • Optional Fields:
    • seed: (integer) Random seed for deterministic outputs, default is 1234.
    • steps: (integer) Number of inference steps, default is 30 (1-100).
    • fileType: (string) Output format (glb, obj, ply, stl), default is glb.
    • guidanceScale: (number) Impact of guidance on generation, default is 5.
    • randomizeSeed: (boolean) Whether to randomize the seed, default is true.
    • numberOfChunks: (integer) Number of chunks for processing, default is 200000.
    • octreeResolution: (integer) Resolution of the octree, default is 256 (16-512).
    • removeBackground: (boolean) Whether to remove background from images, default is true.
    • targetFaceNumber: (integer) Desired number of faces for the resulting mesh, default is 10000 (100-1000000).

Example Input:

{
  "seed": 1234,
  "steps": 30,
  "fileType": "glb",
  "backImage": "https://replicate.delivery/pbxt/MgQTJZJpLfwXQc6N8rcxSAVGGf2GSGWAFYSqyKQyUVadSfiv/dog2-back.png",
  "leftImage": "https://replicate.delivery/pbxt/MgQTKA8In6bsulSoqMd1pp6lhRFmacbXOJuK9swVdknRJSbR/dog2-side.png",
  "frontImage": "https://replicate.delivery/pbxt/MgQTJRO3p8S9ToUYyoMkWLm5edO6y7DZKqP9OZWhYG3zUFtM/dog2-front.png",
  "guidanceScale": 5,
  "randomizeSeed": true,
  "numberOfChunks": 200000,
  "octreeResolution": 256,
  "removeBackground": true,
  "targetFaceNumber": 10000
}

Output

Upon successful execution, this action typically returns a URI link to the generated 3D model file.

Example Output:

https://assets.cognitiveactions.com/invocations/e10c15be-9fb2-4dd8-aff1-18d37ad9b292/58146cbb-e185-4b48-a403-4673eff9ed9a.glb

Conceptual Usage Example (Python)

Here’s how you might call the Generate 3D Models with Multiview Control 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 = "6deef387-64fa-4886-bdf8-fa4cdc8a2665"  # Action ID for Generate 3D Models with Multiview Control

# Construct the input payload based on the action's requirements
payload = {
    "seed": 1234,
    "steps": 30,
    "fileType": "glb",
    "backImage": "https://replicate.delivery/pbxt/MgQTJZJpLfwXQc6N8rcxSAVGGf2GSGWAFYSqyKQyUVadSfiv/dog2-back.png",
    "leftImage": "https://replicate.delivery/pbxt/MgQTKA8In6bsulSoqMd1pp6lhRFmacbXOJuK9swVdknRJSbR/dog2-side.png",
    "frontImage": "https://replicate.delivery/pbxt/MgQTJRO3p8S9ToUYyoMkWLm5edO6y7DZKqP9OZWhYG3zUFtM/dog2-front.png",
    "guidanceScale": 5,
    "randomizeSeed": True,
    "numberOfChunks": 200000,
    "octreeResolution": 256,
    "removeBackground": True,
    "targetFaceNumber": 10000
}

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, replace "YOUR_COGNITIVE_ACTIONS_API_KEY" with your actual API key. The input payload is structured according to the action's requirements, and the response will provide a link to the generated 3D model.

Conclusion

The Tencent Hunyuan3D-2mv Cognitive Actions empower developers to create stunning 3D models with ease. By utilizing the multiview image generation capabilities, you can enhance the quality of your applications and deliver immersive experiences. Explore further use cases like integrating these models into gaming, simulations, or virtual reality environments. Start building today and elevate your projects with high-quality 3D assets!