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)