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 started
  2. GLB Constructor

Easy - Head Visualization

PreviousGLB ConstructorNextAdvanced - Schema preparation

Last updated 1 year ago

At this stage, it is assumed that you have completed the and piplines and obtained uv.png , head_config.json and head.glb files.

token="ENTER_YOUR_TOKEN"

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=@uv.png;type=image/png' \
    -F 'head_config=@head_config.json;type=application/json' \
    -F 'custom_models=@hair.glb;type=image/png' \
    -F 'add_facs=true' > head.glb
import io
import json
import requests

token = "ENTER_YOUR_TOKEN"

if __name__ == "__main__":
    service_url = "https://api.metahumansdk.io/glb_const"
    service_headers = {'accept': 'application/json'}
    
    with open('uv.png', 'rb') as out:
        head_uv = out.read()
    with open('head_config.json', 'r') as out:
        head_config = json.loads(out.read())
    with open('hair.glb', 'rb') as out:
        custom_hair = out.read()

    files = {
        'token': (None, token),
        'head_uv': ('head_model', head_uv, 'image/png'),
        'head_config': ('head_config', json.dumps(head_config), 'application/json'),
        'custom_models': ('custom_models', io.BytesIO(custom_hair), 'application/json'),
        'add_facs': (None, True),
    }

    response = requests.post(service_url + "/assemble", headers=service_headers, files=files)
    assert (response.status_code == 200)
 
    with open("head.glb", "wb") as f:
        f.write(response.content)

After completing all stages, you will get a GLB model head.glb .

3D Face Reconstruction
3D Hair Reconstruction