Live Portrait

Live Portrait animates static images using a reference driving video through implicit key point based framework, bringing a portrait to life with realistic expressions and movements. It identifies key points on the face (think eyes, nose, mouth) and manipulates them to create expressions and movements.

~35.33s
~$0.052
 1import requests
 2import json
 3
 4url = "https://api.segmind.com/v1/live-portrait"
 5headers = {
 6    "x-api-key": "YOUR_API_KEY",
 7    "Content-Type": "application/json"
 8}
 9
10data = {
11    "face_image": "https://segmind-sd-models.s3.amazonaws.com/display_images/liveportrait-input.jpg",
12    "driving_video": "https://segmind-sd-models.s3.amazonaws.com/display_images/liveportrait-video.mp4",
13    "live_portrait_dsize": 512,
14    "live_portrait_scale": 2.3,
15    "video_frame_load_cap": 128,
16    "live_portrait_lip_zero": true,
17    "live_portrait_relative": true,
18    "live_portrait_vx_ratio": 0,
19    "live_portrait_vy_ratio": -0.12,
20    "live_portrait_stitching": true,
21    "video_select_every_n_frames": 1,
22    "live_portrait_eye_retargeting": false,
23    "live_portrait_lip_retargeting": false,
24    "live_portrait_lip_retargeting_multiplier": 1,
25    "live_portrait_eyes_retargeting_multiplier": 1
26}
27
28response = requests.post(url, headers=headers, json=data)
29
30if response.status_code == 200:
31    result = response.json()
32    print(json.dumps(result, indent=2))
33else:
34    print(f"Error: {response.status_code}")
35    print(response.text)

API Endpoint

POSThttps://api.segmind.com/v1/live-portrait

Parameters

driving_videorequired
string (uri)

A video to drive the animation

Default: "https://segmind-sd-models.s3.amazonaws.com/display_images/liveportrait-video.mp4"
face_imagerequired
string (uri)

An image with a face

Default: "https://segmind-sd-models.s3.amazonaws.com/display_images/liveportrait-input.jpg"
live_portrait_dsizeoptional
integer

Size of the output image

Default: 512Range: 64 - 2048
live_portrait_eye_retargetingoptional
boolean

Enable eye retargeting

Default: false
live_portrait_eyes_retargeting_multiplieroptional
number

Multiplier for eye retargeting

Default: 1Range: 0.01 - 10
live_portrait_lip_retargetingoptional
boolean

Enable lip retargeting

Default: false
live_portrait_lip_retargeting_multiplieroptional
number

Multiplier for lip retargeting

Default: 1Range: 0.01 - 10
live_portrait_lip_zerooptional
boolean

Enable lip zero

Default: true
live_portrait_relativeoptional
boolean

Use relative positioning

Default: true
live_portrait_scaleoptional
number

Scaling factor for the face

Default: 2.3Range: 1 - 4
live_portrait_stitchingoptional
boolean

Enable stitching

Default: true
live_portrait_vx_ratiooptional
number

Horizontal shift ratio

Default: 0Range: -1 - 1
live_portrait_vy_ratiooptional
number

Vertical shift ratio

Default: -0.12Range: -1 - 1
video_frame_load_capoptional
integer

The maximum number of frames to load from the driving video. Set to 0 to use all frames.

Default: 128
video_select_every_n_framesoptional
integer

Select every nth frame from the driving video. Set to 1 to use all frames.

Default: 1

Response Type

Returns: Video

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out