Enhance Video Quality Effortlessly with Stable Video Face Restoration Actions

24 Apr 2025
Enhance Video Quality Effortlessly with Stable Video Face Restoration Actions

In today's digital age, video content is everywhere, and ensuring high-quality visuals is crucial for user engagement. The Stable Video Face Restoration (SVFR) Cognitive Actions offer developers a powerful way to enhance and restore facial details in degraded videos. This set of pre-built actions allows for various tasks, including facial detail enhancement, colorization, and complete restoration with inpainting. By integrating SVFR, developers can significantly improve the quality and details of front-facing video content, creating a more immersive experience for viewers.

Prerequisites

To utilize the Cognitive Actions effectively, you'll need:

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of making HTTP requests and handling JSON data.
  • A suitable environment set up for running Python scripts.

Authentication typically involves passing your API key in the headers of your requests.

Cognitive Actions Overview

Enhance Video Face Restoration with SVFR

Description:
This action utilizes Stable Video Face Restoration to enhance and restore facial details in degraded videos. It is particularly effective for front-facing videos and can perform tasks such as face restoration, colorization, and inpainting.

Category: Video Enhancement

Input

The input for this action is structured as follows:

  • video (string, required): URI pointing to the input video file (e.g., MP4 format).
  • tasks (string, optional): Specifies tasks to apply. Options include:
    • face-restoration
    • face-restoration-and-colorization
    • face-restoration-and-colorization-and-inpainting
  • mask (string, optional): URI for an inpainting mask image; required only if inpainting tasks include.
  • seed (integer, optional): Seed for random number generation. A value of -1 uses a random seed.
  • overlap (integer, optional): Number of overlapping frames between video segments (default is 3).
  • decodeChunkSize (integer, optional): Chunk size for decoding long videos (default is 16).
  • maxGuidanceScale (number, optional): Maximum scale for guidance in restoration (default is 2).
  • minGuidanceScale (number, optional): Minimum scale for guidance in restoration (default is 2).
  • numberOfInferenceSteps (integer, optional): Number of steps in the diffusion process (default is 30).
  • imageToImageNoiseStrength (number, optional): Strength of noise for image-to-image tasks (default is 1).
  • noiseAugmentationStrength (number, optional): Strength of noise augmentation (default is 0).

Example Input:

{
  "seed": -1,
  "tasks": "face-restoration-and-colorization",
  "video": "https://replicate.delivery/pbxt/MIbOOPKJQB3eK97fsGICCI7ofRkWnEXALKHE3PgNaGi47utI/lq2.mp4"
}

Output

Upon successful execution, the action typically returns a URI pointing to the enhanced video file.

Example Output:

https://assets.cognitiveactions.com/invocations/bbc2ab4f-eca8-400c-993c-de7e38838eab/d1aa1ef1-8f71-47de-bcc2-83555ef11e38.mp4

Conceptual Usage Example (Python)

Below is a conceptual Python code snippet demonstrating how to invoke the SVFR action:

import requests
import json

# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"  # Hypothetical endpoint

action_id = "ca6ec178-2b81-4032-971b-2891370f53b8"  # Action ID for Enhance Video Face Restoration with SVFR

# Construct the input payload based on the action's requirements
payload = {
    "seed": -1,
    "tasks": "face-restoration-and-colorization",
    "video": "https://replicate.delivery/pbxt/MIbOOPKJQB3eK97fsGICCI7ofRkWnEXALKHE3PgNaGi47utI/lq2.mp4"
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json={"action_id": action_id, "inputs": payload}  # Hypothetical structure
    )
    response.raise_for_status()  # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body: {e.response.text}")

In this code snippet, you would replace the placeholder with your actual API key and the hypothetical endpoint. The payload is structured according to the action's requirements, and the response is printed out for further examination.

Conclusion

The Stable Video Face Restoration Cognitive Actions empower developers to elevate their video content quality seamlessly. By utilizing these actions, you can enhance facial details, colorize videos, and restore degraded footage, providing a richer viewing experience. Consider experimenting with different combinations of tasks and parameters to find the perfect enhancement for your videos. Happy coding!