Transform Your Images into Stunning 3D Assets with Wonder3D

Wonder3D is an innovative service that allows developers to create impressive 3D assets from simple front-facing images. By leveraging the power of advanced 3D reconstruction techniques, Wonder3D offers quick results with automatic background removal options, making it easier than ever to enhance your projects with engaging 3D models. Whether you are working on game development, virtual reality experiences, or product visualization, Wonder3D can simplify the process of 3D asset creation.
Prerequisites
To get started with Wonder3D, you will need a Cognitive Actions API key and a basic understanding of API calls. This will enable you to seamlessly integrate the capabilities of Wonder3D into your applications.
Generate 3D Asset from Image
The "Generate 3D Asset from Image" action allows you to transform a single front-facing image into a fully realized 3D asset. This action addresses the challenge of creating 3D models from 2D images, providing a rapid and efficient solution for developers looking to expand their asset libraries.
Input Requirements:
- Image: The URI of the input image that you want to convert to a 3D format. For example:
https://replicate.delivery/pbxt/JsjxC7Lc2J1G4fE4nP84HflbG4gdlfQ1TbVpRjkz90Wdz7EQ/sample2.png - Random Seed (optional): An integer that specifies the random seed for reproducibility in the conversion process. Leaving this blank will yield different random outputs each time.
- Number of Steps: An integer between 100 and 10,000 that defines the number of iterations for processing the image (default is set to 3,000).
- Remove Background: A boolean value indicating whether the background should be removed from the input image. The default is set to true.
Expected Output:
The output will be a URI linking to the generated 3D asset, which can be used in various applications. For instance: https://assets.cognitiveactions.com/invocations/1215dc81-0cb9-45ca-96f7-9ca1fd6a43c7/e6edf029-3635-482c-b78b-565253432e8d.glb
Use Cases for this Specific Action:
- Game Development: Quickly generate 3D character models or assets from concept art or photographs, significantly speeding up the asset creation process.
- E-commerce: Create 3D product models from images, allowing customers to view products from multiple angles, enhancing their shopping experience.
- Virtual Reality: Develop immersive environments by converting real-world images into 3D assets, making virtual experiences more engaging and realistic.
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 = "0d02cf4a-9cab-4610-8a6e-ebd0b6feb67f" # Action ID for: Generate 3D Asset from Image
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"image": "https://replicate.delivery/pbxt/JsjxC7Lc2J1G4fE4nP84HflbG4gdlfQ1TbVpRjkz90Wdz7EQ/sample2.png",
"numberOfSteps": 3000,
"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
Wonder3D's capabilities to transform images into 3D assets provide developers with a powerful tool to enhance their applications, whether for gaming, e-commerce, or virtual reality. By automating the 3D asset creation process, developers can save time and resources while producing high-quality results. To explore the potential of Wonder3D, start integrating these actions into your projects today and unlock new possibilities in your creative workflow.