Live Portrait Serverless API
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.
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) 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
https://api.segmind.com/v1/live-portraitParameters
driving_videorequiredstring (uri)A video to drive the animation
"https://segmind-sd-models.s3.amazonaws.com/display_images/liveportrait-video.mp4"face_imagerequiredstring (uri)An image with a face
"https://segmind-sd-models.s3.amazonaws.com/display_images/liveportrait-input.jpg"live_portrait_dsizeoptionalintegerSize of the output image
512Range: 64 - 2048live_portrait_eye_retargetingoptionalbooleanEnable eye retargeting
falselive_portrait_eyes_retargeting_multiplieroptionalnumberMultiplier for eye retargeting
1Range: 0.01 - 10live_portrait_lip_retargetingoptionalbooleanEnable lip retargeting
falselive_portrait_lip_retargeting_multiplieroptionalnumberMultiplier for lip retargeting
1Range: 0.01 - 10live_portrait_lip_zerooptionalbooleanEnable lip zero
truelive_portrait_relativeoptionalbooleanUse relative positioning
truelive_portrait_scaleoptionalnumberScaling factor for the face
2.3Range: 1 - 4live_portrait_stitchingoptionalbooleanEnable stitching
truelive_portrait_vx_ratiooptionalnumberHorizontal shift ratio
0Range: -1 - 1live_portrait_vy_ratiooptionalnumberVertical shift ratio
-0.12Range: -1 - 1video_frame_load_capoptionalintegerThe maximum number of frames to load from the driving video. Set to 0 to use all frames.
128video_select_every_n_framesoptionalintegerSelect every nth frame from the driving video. Set to 1 to use all frames.
1Response Type
Returns: Video
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out