Create Stunning 3D Textured Assets Easily with Hunyuan3d 2

26 Apr 2025
Create Stunning 3D Textured Assets Easily with Hunyuan3d 2

In the ever-evolving world of 3D modeling and design, developers are constantly seeking tools that enhance creativity while simplifying workflows. Hunyuan3d 2 offers a powerful solution through its Cognitive Actions, specifically designed to generate high-resolution 3D textured assets. Utilizing advanced diffusion models, this service allows developers to transform input images into detailed and realistic 3D shapes efficiently. The ability to control various parameters such as inference steps, guidance scale, and octree resolution means that you can tailor outputs to meet your specific project needs.

Common use cases for Hunyuan3d 2 include creating assets for video games, virtual reality environments, and product visualizations. Whether you're a game developer looking to generate unique character models or an architect needing realistic representations of buildings, Hunyuan3d 2 streamlines the asset creation process, saving you time and resources.

Prerequisites

To get started, you will need an API key for Cognitive Actions and a basic understanding of making API calls.

Generate High-Resolution 3D Textured Assets

The primary action offered by Hunyuan3d 2 is the generation of high-resolution 3D textured assets. This action is designed to create intricate 3D models from input images, solving the problem of time-consuming manual modeling and texturing.

Input Requirements

The action requires a CompositeRequest object with the following properties:

  • Seed: An integer for random seed generation, defaulting to 1234 for reproducibility.
  • Image: A URI pointing to an input image that will be transformed into a 3D shape. The image must be publicly accessible online.
  • Steps: An integer between 20 and 50 that specifies the number of inference steps for the generation process, with a default of 50.
  • Guidance Scale: A number that adjusts the influence of guidance during generation, ranging from 1 to 20, with a default of 5.5.
  • Octree Resolution: An integer that defines the octree resolution for mesh generation, selectable from 256, 384, or 512, with a default of 512.
  • Remove Background: A boolean indicating whether to remove the background from the input image, defaulting to true to enhance focus on the primary object.

Example Input

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

Expected Output

The action will generate a 3D mesh asset, which can be accessed via a URI. This output allows for immediate integration into various applications or further manipulation in design software.

Example Output

{
  "mesh": "https://assets.cognitiveactions.com/invocations/e8e9a00b-5794-4965-b398-858e21ed7b30/e270d053-2506-464e-aaa4-057bca56e54f.glb"
}

Use Cases for this Specific Action

This action is ideal for developers who need to quickly generate high-quality 3D models from 2D images. Possible scenarios include:

  • Game Development: Automatically create diverse character models or environments based on concept art.
  • E-commerce: Generate realistic product models for online stores, enhancing customer engagement with 3D views.
  • Architecture Visualization: Transform architectural designs into 3D models for client presentations, allowing for better spatial understanding.
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 = "bc909847-7f9d-466b-a2f2-d0cc6181768b" # Action ID for: Generate High-Resolution 3D Textured Assets

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
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",
    # 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

Hunyuan3d 2's capability to generate high-resolution 3D textured assets from simple input images presents a significant advancement for developers in various fields. By simplifying the asset creation process, it not only saves time but also allows for greater creative exploration. As you integrate Hunyuan3d 2 into your projects, consider the numerous applications of its features and how they can enhance your workflow. Start experimenting with the API today to unlock the full potential of 3D asset generation!