3. Start Try-on Task

1 Function description

Tell the back end to start the inference task,please ensure that you have successfully uploaded the image

Note that In addition to the points for try-on, each api call will consume 0.1 coins.

2 Request method

method:POST URL :{ApiUrl}/api/inf/public_inf

3 Request parameter

nametypedescribesample

openId

string

your openId

apiKey

string

our apiKey

clothId

long

which cloth

208

infId

long

task id

2880

bmi

float

user's bmi

22.2

skin

float

skin color (-100:auto 0--6 white--black)

-100

notifyUrl

string

callback function address

    clothId = 208 # The number of the garment can be seen on the website
    height = 1.70 # User's height, 170 cm =1.7 m
    weight = 65 # Weight of the user, 65 kg
    skin = -100 # -100 auto detect 0:white 6:black
    bmi = weight/(height*height) # To calculate bmi, the caller needs to calculate it himself
    print(bmi)
    params = {'openId':OpenId, 'apiKey':ApiKey, 'infId':infId, 
        'clothId':clothId, 'bmi':bmi, 'skin':skin}
    session = requests.session()
    ret = requests.post(f"{ApiUrl}/api/inf/public_inf", data=json.dumps(params))
    if ret.status_code==200:
        print(ret.json())
        if 'data' in ret.json():
            """
                [Success] An example returns the result
                {'code': 200, 'msg': 'ok', 'data': True}
            """
            print('Successfully publish a task')
           """
                [failed] An example returns the result
                If the returned result is false, it means that the image legality check failed, mostly because the face was not detected, or a headshot was uploaded.
                call {ApiUrl}/api/inf/get_result, to get fail result
                {'code': 200, 'msg': 'ok', 'data': False}
            """
        else:
            print('Publishing task failure')
            exit(0)
    else:
        exit(0)

4 Respond

  • success

{'code': 200, 'msg': 'ok', 'data': True}
  • failed

If the returned result is false, it means that the image legality check failed, mostly because the face was not detected, or a headshot was uploaded. Call {ApiUrl}/api/inf/get_result, to get fail result

{'code': 200, 'msg': 'ok', 'data': False}

Last updated