Advanced - Schema preparation
1. Getting a token
2. Creating a schema
You must describe all your types and model IDs in a JSON file. For example, you have 2 types of models - body and hair. The JSON structure will then look like this:
{
"hair" : [ # <- model type
"hairM_01", "hairF_01" # <- model id
],
"body": [
"body_01", "body_02", "body_03"
]
}In this example, 5 models are declared: 2 body IDs and 3 hairstyle IDs.
You can also leave the JSON empty, then when assembled, only the head will be generated.
{
}Note: You can't do nested model types. there are only 2 levels: types and IDs.
Sending your schema.
token="ENTER_YOUR_TOKEN"
schema_path="ENTER_SCHEMA_PATH"
curl -X 'PUT' \
'https://api.metahumansdk.io/glb_const/schema' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F "token=$token" \
-F "schema=@$schema_path;type=application/json"import requests
schema_path = "ENTER_SCHEMA_PATH"
token = "ENTER_YOUR_TOKEN"
if __name__ == "__main__":
service_url = "https://api.metahumansdk.io/glb_const"
service_headers = {"accept": "application/json"}
files = {
"token": (None, token),
"schema": ("schema.json", open(schema_path, 'r'), "application/json")
}
response = requests.put(service_url + "/schema", headers=service_headers, files=files)
assert (response.status_code == 200)
assert ('result' in response.json())
print(response.json())You should get:
{
"result": {
"status": "schema loaded successfully"
}
}4. Uploading GLB models
You must add all the models declared in the schema.
Sending your GLB file.
token="ENTER_YOUR_TOKEN"
glb_path="ENTER_GLB_PATH"
glb_hash="ENTER_GLB_HASH"
data_type="ENTER_DATA_TYPE"
data_id="ENTER_DATA_ID"
curl -X 'PUT' \
'https://api.metahumansdk.io/glb_const/glb' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F "token=$token" \
-F "data=@$glb_path" \
-F "sha256=$glb_hash" \
-F "data_type=$data_type" \
-F "data_id=$data_id"import requests
token="ENTER_YOUR_TOKEN"
glb_path="ENTER_GLB_PATH"
glb_hash="ENTER_GLB_HASH"
data_type="ENTER_DATA_TYPE"
data_id="ENTER_DATA_ID"
if __name__ == "__main__":
service_url = "https://api.metahumansdk.io/glb_const"
service_headers = {"accept": "application/json"}
files = {
"token": (None, token),
"data": ("model", open(glb_path, "rb"), "model/gltf-binary"),
"sha256": (None, glb_hash),
"data_type": (None, data_type),
"data_id": (None, data_id)
}
response = requests.put(service_url + "/glb", headers=service_headers, files=files)
assert (response.status_code == 200)
assert ('result' in response.json())
print(response.json())You should get:
{
"result": {
"status": "model loaded successfully"
}
}Last updated