Service APIs for creating virtual avatars
  • Welcome
    • Overview
    • About us
    • Glossary
  • What's New
    • Changelog
    • Subscribe for updates
  • EXAMPLES
    • 3D model from single photo
  • Getting started
    • Introduction
    • Getting a token
    • 3D Face Reconstruction
    • 3D Hair Reconstruction
    • GLB Constructor
      • Easy - Head Visualization
      • Advanced - Schema preparation
      • Advanced - Assembling
  • API Methods
    • 3D Face Reconstruction
      • Bad Case Examples
    • 3D Hair Reconstruction
    • GLB Constructor
  • Errors
    • 3D Face Reconstruction
    • 3D Hair Reconstruction
    • GLB Constructor
  • API Metrics
    • SLA
Powered by GitBook
On this page
  • 1. Getting a token
  • 2. Get data for model construction
  • 4. Create models config
  • 3. Make a request
  • 4. Check response
  1. Getting started
  2. GLB Constructor

Advanced - Assembling

PreviousAdvanced - Schema preparationNext3D Face Reconstruction

Last updated 2 years ago

1. Getting a token

2. Get data for model construction

Note: This service only works with parameters from the

Need to have:

  • JSON with parameters (head_config.json in example)

  • UV face texture (my_unique_image_name_texture.png in example)

  • (optional)

4. Create models config

Models config is the JSON file with the pairs of model IDs for the model types from the scheme that you want to add to the finished GLB file.

For example, if you want to add body_02 from the schema (and don't add hair), models config should look like this:

models_config.json
{
	"body": [
		"body_02"
	]
}

3. Make a request

Make a request by sending the files above.

token="ENTER_YOUR_TOKEN"
head_uv="ENTER_UV_PATH"
head_config="ENTER_HEAD_CONFIG_PATH"
model_config="ENTER_MODEL_CONFIG_PATH"

 curl -X POST\
    'https://api.metahumansdk.io/glb_const/assemble' \
   -H 'accept: application/json' \
   -H 'Content-Type: multipart/form-data' \
   -F "token=$token" \
   -F "head_uv=@$head_uv;type=image/png" \
   -F "head_config=@$head_config;type=application/json" \
   -F "models_config=@$model_config;type=application/json" \
   -F 'add_facs=true' > model.glb
import json
import requests

token="ENTER_YOUR_TOKEN"
head_uv="ENTER_UV_PATH"
head_config="ENTER_HEAD_CONFIG_PATH"
model_config="ENTER_MODEL_CONFIG_PATH"

if __name__ == "__main__":
    service_url = "https://api.metahumansdk.io/glb_const"
    headers = {
        "accept": "application/json",
    }

    files = {
        "token": (None, token),
        "head_uv": ("head_model", open(head_uv, "rb"), "image/png"),
        "head_config": ("head_config", open(head_config, 'rb'), "application/json"),
        "models_config": ("models_config", open(model_config, 'rb'), "application/json"),
        "add_facs": (None, True)
    }

    response = requests.post(service_url + "/assemble", headers=headers, files=files)

    assert response.status_code == 200

    with open('model.glb', "wb") as f:
        f.write(response.content)

4. Check response

Open the GLB file in the GLB viewer. For example, you can import the GLB file in Blender.

Rendering in Maya:

Getting a token
3D Face Reconstruction Service
reconstructed hair model