Rodin Generation
Rodin生成
使用此API向我们的服务器提交异步任务。你将从API中获得一个任务UUID,该UUID可用于检查进度和下载结果。
价格
Note: 参数不会收取任何额外费用,只有模型附加项才会有额外收费。
Base Cost: `
Sketch`
和`Regular`
每次生成消耗 0.5 Credit。Addons:
HighPack
: 每次生成额外消耗 1 Credit。
请求
Note: 所有到这个端点的请求都必须使用multipart/form-data
发送,以正确处理文件上传以及网格和纹理生成过程所需的其他参数。
Authentication
此API使用密钥进行身份验证。您需要在所有请求的Authorization
头中包含一个有效的密钥. 参阅快速开始获取您的账户的API生成密钥。
Authorization: Bearer RODIN_API_KEY
Body
Rodin提供两种生成模式: Text-to-3D 和 Image-to-3D. Image-to-3D: 当你将图片文件作为参数上传,Rodin会执行Image-to-3D生成,您可以上传一张或多张图片。当上传多张图片时,
fuse
模式将融合图片特征来生成模型。concat
模式需要您上传同一事物的多张多视角图片用于生成。
Text-to-3D: 当您没有上传任何图片文件,Rodin会执行Text-to-3D生成,您必须上传Prompt参数。
ControlNet: ControlNet通过对生成的输出提供更精细的控制来增强模型定制。它在原始API的基础上添加了几个参数,允许用户操作3D模型的比例、形状和结构等方面。
ControlNet引入以下主要参数,以提供对模型生成过程的高级控制:
BoundingBox ControlNet: BoundingBox ControlNet允许用户通过可拖动的边界框指定长度、宽度和高度来定义生成模型的比例。当您希望生成的对象适合特定的尺寸或遵循特定的空间约束时,这尤其有用。
样例:
{ "bbox_condition": [ 100, 100, 100 ] }
bbox_condition: 指定边界框的尺寸和缩放因子的数组。
元素:
Length (X-axis):
100
units.Width (Y-axis):
100
units.Height (Z-axis):
100
uints.
通过设置
bbox_condition
,您将指示模型生成一个适合指定尺寸的长方体对象。Bounding Box Axis:
World +z(Height) | | |______+y(Width) / / / +x(Length)
响应
对于response from the Generation API的task_uuid
,使用uuid
字段替代jobs_uuid
。
代码示例
Minimal Rodin Regular Generation(Image-to-3D)
export RODIN_API_KEY="your api key"
curl https://hyperhuman.deemos.com/api/v2/rodin \
-H "Authorization: Bearer ${RODIN_API_KEY}" \
-F "images=@/path/to/your/image.jpg"
unset RODIN_API_KEY
import os
import requests
# Constants
ENDPOINT = "https://hyperhuman.deemos.com/api/v2/rodin"
API_KEY = "your api key" # Replace with your actual API key
IMAGE_PATH = "/path/to/your/image.jpg" # Replace with the path to your image
# Prepare the multipart form data
files = [
('images', open(IMAGE_PATH, 'rb')),
]
# Prepare the headers
headers = {
'Authorization': f'Bearer {API_KEY}',
}
# Make the POST request
response = requests.post(ENDPOINT, files=files, headers=headers)
# Parse and return the JSON response
print(response.json())
package main
import (
"bytes"
"encoding/json"
"fmt"
"mime/multipart"
"net/http"
"os"
"path/filepath"
)
const BaseURI = "https://hyperhuman.deemos.com/api"
type CommonError struct {
Error *string `json:"error,omitempty"`
Message *string `json:"message,omitempty"`
}
type JobSubmissionResponse struct {
Uuids []string `json:"uuids"`
SubscriptionKey string `json:"subscription_key"`
}
type RodinAllInOneResponse struct {
CommonError
Uuid *string `json:"uuid,omitempty"`
Jobs JobSubmissionResponse `json:"jobs,omitempty"`
}
func RunRodin(token string, filePath string) (*RodinAllInOneResponse, error) {
var err error
var buffer bytes.Buffer
// Create the form data for Rodin API
writer := multipart.NewWriter(&buffer)
// Read the image
image, err := os.ReadFile(filePath)
if err != nil {
return nil, err
}
// Add the image as a form entry
fieldWriter, err := writer.CreateFormFile("images", filepath.Base(filePath))
if err != nil {
return nil, err
}
if _, err = fieldWriter.Write(image); err != nil {
return nil, err
}
err = writer.Close()
if err != nil {
return nil, err
}
// Create the request
req, err := http.NewRequest("POST", fmt.Sprintf("%s/v2/rodin", BaseURI), &buffer)
if err != nil {
return nil, err
}
// Set headers
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Content-Type", writer.FormDataContentType())
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var responseData RodinAllInOneResponse
err = json.NewDecoder(resp.Body).Decode(&responseData)
if err != nil {
return nil, err
}
if responseData.Error != nil {
return nil, fmt.Errorf("%s: %s", *responseData.Error, *responseData.Message)
}
return &responseData, nil
}
func main() {
// Replace with your actual API key
token := "your api key"
// Replace with the path to your image
resp, _ := RunRodin(token, "/path/to/your/image.jpg")
fmt.Println(resp)
}
{
"error": null,
"message": "Submitted.",
"uuid": "123e4567-e89b-12d3-a456-426614174000",
"jobs": {
"uuids": ["job-uuid-1", "job-uuid-2"],
"subscription_key": "sub-key-1"
}
}
Minimal Rodin Sketch Generation(Image-to-3D)
export RODIN_API_KEY="your api key"
curl https://hyperhuman.deemos.com/api/v2/rodin \
-H "Authorization: Bearer ${RODIN_API_KEY}" \
-F "images=@/path/to/your/image.jpg" \
-F "tier=Sketch"
unset RODIN_API_KEY
import os
import requests
# Constants
ENDPOINT = "https://hyperhuman.deemos.com/api/v2/rodin"
API_KEY = "your api key" # Replace with your actual API key
IMAGE_PATH = "/path/to/your/image.jpg" # Replace with the path to your image
# Read the image file
with open(IMAGE_PATH, 'rb') as image_file:
image_data = image_file.read()
# Prepare the multipart form data
files = {
'images': (os.path.basename(IMAGE_PATH), image_data, 'image/jpeg')
}
# Set the tier to Rodin Sketch
data = {
'tier': 'Sketch',
}
# Prepare the headers
headers = {
'Authorization': f'Bearer {API_KEY}',
}
# Make the POST request
response = requests.post(ENDPOINT, files=files, data=data, headers=headers)
# Parse and return the JSON response
print(response.json())
package main
import (
"bytes"
"encoding/json"
"fmt"
"mime/multipart"
"net/http"
"os"
"path/filepath"
)
const BaseURI = "https://hyperhuman.deemos.com/api"
type CommonError struct {
Error *string `json:"error,omitempty"`
Message *string `json:"message,omitempty"`
}
type JobSubmissionResponse struct {
Uuids []string `json:"uuids"`
SubscriptionKey string `json:"subscription_key"`
}
type RodinAllInOneResponse struct {
CommonError
Uuid *string `json:"uuid,omitempty"`
Jobs JobSubmissionResponse `json:"jobs,omitempty"`
}
func RunRodin(token string, filePath string) (*RodinAllInOneResponse, error) {
var err error
var buffer bytes.Buffer
// Create the form data for Rodin API
writer := multipart.NewWriter(&buffer)
// Read the image
image, err := os.ReadFile(filePath)
if err != nil {
return nil, err
}
// Add the image as a form entry
fieldWriter, err := writer.CreateFormFile("images", filepath.Base(filePath))
if err != nil {
return nil, err
}
if _, err = fieldWriter.Write(image); err != nil {
return nil, err
}
// Set the tier to Rodin Sketch
fieldWriter, err = writer.CreateFormField("tier")
if err != nil {
return nil, err
}
if _, err = fieldWriter.Write([]byte("Sketch")); err != nil {
return nil, err
}
err = writer.Close()
if err != nil {
return nil, err
}
// Create the request
req, err := http.NewRequest("POST", fmt.Sprintf("%s/v2/rodin", BaseURI), &buffer)
if err != nil {
return nil, err
}
// Set headers
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Content-Type", writer.FormDataContentType())
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var responseData RodinAllInOneResponse
err = json.NewDecoder(resp.Body).Decode(&responseData)
if err != nil {
return nil, err
}
if responseData.Error != nil {
return nil, fmt.Errorf("%s: %s", *responseData.Error, *responseData.Message)
}
return &responseData, nil
}
func main() {
// Replace with your actual API key
token := "your api key"
// Replace with the path to your image
resp, _ := RunRodin(token, "/path/to/your/image.jpg")
fmt.Println(resp)
}
{
"error": null,
"message": "Submitted.",
"uuid": "123e4567-e89b-12d3-a456-426614174000",
"jobs": {
"uuids": ["job-uuid-1", "job-uuid-2"],
"subscription_key": "sub-key-1"
}
}
Minimal Rodin Generation(Text-to-3D)
export RODIN_API_KEY="your api key"
curl https://hyperhuman.deemos.com/api/v2/rodin \
-H "Authorization: Bearer ${RODIN_API_KEY}" \
-F "prompt=A 3D model of a futuristic robot" \
unset RODIN_API_KEY
{
"error": null,
"message": "Submitted.",
"uuid": "123e4567-e89b-12d3-a456-426614174000",
"jobs": {
"uuids": ["job-uuid-1", "job-uuid-2"],
"subscription_key": "sub-key-1"
}
}
Minimal Rodin Generation(Image-to-3D with multi-view images)
export RODIN_API_KEY="your api key"
curl https://hyperhuman.deemos.com/api/v2/rodin \
-H "Authorization: Bearer ${RODIN_API_KEY}" \
-F 'condition_mode=concat' \
-F "images=@/path/to/your/image_0.jpg" \
-F "images=@/path/to/your/image_1.jpg"
unset RODIN_API_KEY
import os
import requests
# Constants
ENDPOINT = "https://hyperhuman.deemos.com/api/v2/rodin"
API_KEY = "your api key" # Replace with your actual API key
IMAGE_PATH_0 = "/path/to/your/image_0.jpg" # Replace with the path to your image_0
IMAGE_PATH_1 = "/path/to/your/image_1.jpg" # Replace with the path to your image_1
# Prepare the multipart form data
files = [
('images', open(IMAGE_PATH_0, 'rb')),
('images', open(IMAGE_PATH_1, 'rb')),
]
# Prepare the headers
headers = {
'Authorization': f'Bearer {API_KEY}',
}
# Make the POST request
response = requests.post(ENDPOINT, files=files, headers=headers)
# Parse and return the JSON response
print(response.json())
{
"error": null,
"message": "Submitted.",
"uuid": "123e4567-e89b-12d3-a456-426614174000",
"jobs": {
"uuids": ["job-uuid-1", "job-uuid-2"],
"subscription_key": "sub-key-1"
}
}
Minimal Rodin ControlNet Generation(Bounding Box Condition)
export RODIN_API_KEY="your api key"
curl https://hyperhuman.deemos.com/api/v2/rodin \
-H "Authorization: Bearer ${RODIN_API_KEY}" \
-F "bbox_condition=[100,100,100]"
-F "prompt=A sofa."
unset RODIN_API_KEY
import os
import requests
# Constants
ENDPOINT = "https://hyperhuman.deemos.com/api/v2/rodin"
API_KEY = "your api key" # Replace with your actual API key
IMAGE_PATH = "/path/to/your/image.jpg" # Replace with the path to your image
# Read the image file
with open(IMAGE_PATH, 'rb') as image_file:
image_data = image_file.read()
# Prepare the images data
files = {
'images': (os.path.basename(IMAGE_PATH), image_data, 'image/jpeg')
}
# Prepare the Bounding Box data
data = {
"bbox_condition":[
100,
100,
100
]
}
# Prepare the headers
headers = {
'Authorization': f'Bearer {API_KEY}',
}
# Make the POST request
response = requests.post(ENDPOINT, files=files, data=data, headers=headers)
# Parse and return the JSON response
print(response.json())
{
"error": null,
"message": "Submitted. Please check progress via /api/v2/status and get download link via /api/v2/download",
"uuid": "123e4567-e89b-12d3-a456-426614174000",
"jobs": {
"uuids": ["job-uuid-1", "job-uuid-2"],
"subscription_key": "sub-key-1"
}
}
Comprehensive Rodin Regular Generation with All Parameters
export RODIN_API_KEY="your api key"
curl https://hyperhuman.deemos.com/api/v2/rodin \
-H "Authorization: Bearer ${RODIN_API_KEY}" \
-F "images=@/path/to/your/image.jpg" \
-F "prompt=A 3D model of a futuristic robot" \
-F "seed=42" \
-F "geometry_file_format=fbx" \
-F "material=PBR" \
-F "quality=high" \
-F "use_hyper=true" \
-F "tier=Regular" \
-F "addons=HighPack"
unset RODIN_API_KEY
{
"error": null,
"message": "Submitted.",
"uuid": "123e4567-e89b-12d3-a456-426614174000",
"jobs": {
"uuids": ["job-uuid-1", "job-uuid-2"],
"subscription_key": "sub-key-1"
}
}
最后更新于