Create Stunning Transition Videos with the leclem/seine-transition Cognitive Actions

21 Apr 2025
Create Stunning Transition Videos with the leclem/seine-transition Cognitive Actions

In the evolving landscape of digital content creation, the ability to generate high-quality media is paramount. The leclem/seine-transition API offers developers a powerful Cognitive Action designed to produce captivating video transitions between images. By leveraging the SEINE video diffusion model, this API enables seamless transitions, enhancing user experiences in applications ranging from social media to creative design tools.

Prerequisites

Before diving into the integration of the Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of making HTTP requests and handling JSON data.

Authentication typically involves including your API key in the request headers, allowing you to securely access the action functionalities.

Cognitive Actions Overview

Generate Image Transition Video

The Generate Image Transition Video action is designed to create a smoothly transitioning video that merges two images. This high-quality generative transition can be utilized for a variety of applications, such as storytelling, presentations, and artistic displays.

Input

The action requires a specific input schema, which includes both required and optional fields:

  • image (string, required): The URI of the input image that appears at the beginning of the video.
  • endImage (string, required): The URI of the input image that appears at the end of the video.
  • seed (integer, optional): Random seed for reproducibility. Leave blank to generate a random seed.
  • width (integer, optional): The width of the video in pixels (default: 560).
  • height (integer, optional): The height of the video in pixels (default: 240).
  • runTime (integer, optional): Total run time of the video in seconds (default: 13).
  • numberOfFrames (integer, optional): Total number of frames in the video (default: 16).
  • numberOfSamplingSteps (integer, optional): Number of sampling steps for processing (default: 250).
  • classifierFreeGuidanceScale (number, optional): Scale factor for classifier-free guidance (default: 8, range: 1-50).

Example Input:

{
  "image": "https://replicate.delivery/pbxt/Khu4yYZEezSFJZFgny7CoWgJH2pjaGEuLtelwUQuRlrNRxgm/spiderman.png",
  "width": 512,
  "height": 512,
  "runTime": 13,
  "endImage": "https://replicate.delivery/pbxt/Khu4yk3wAon2zqWusnxdiNGsryV19z54oPtjKFMLbuazHdG5/sand.png",
  "numberOfFrames": 16,
  "numberOfSamplingSteps": 250,
  "classifierFreeGuidanceScale": 8
}

Output

Upon successful execution, the action returns a URL pointing to the generated video. This output can be utilized in applications to display the transition seamlessly.

Example Output:

https://assets.cognitiveactions.com/invocations/5833350c-4327-46f1-9cf9-8d664b245c8c/46076c85-5eda-4a42-bb15-bf7b1cfac553.mp4

Conceptual Usage Example (Python)

Here’s how you might invoke the Generate Image Transition Video action using Python:

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 = "70586dea-0582-40b1-9f34-54d29094cf03" # Action ID for Generate Image Transition Video

# Construct the input payload based on the action's requirements
payload = {
    "image": "https://replicate.delivery/pbxt/Khu4yYZEezSFJZFgny7CoWgJH2pjaGEuLtelwUQuRlrNRxgm/spiderman.png",
    "width": 512,
    "height": 512,
    "runTime": 13,
    "endImage": "https://replicate.delivery/pbxt/Khu4yk3wAon2zqWusnxdiNGsryV19z54oPtjKFMLbuazHdG5/sand.png",
    "numberOfFrames": 16,
    "numberOfSamplingSteps": 250,
    "classifierFreeGuidanceScale": 8
}

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, replace the placeholder API key with your actual key. The action_id corresponds to the Generate Image Transition Video action. The input payload is structured according to the action requirements, allowing for a smooth transition between the specified images.

Conclusion

The leclem/seine-transition Cognitive Actions provide a robust toolset for developers looking to create dynamic video transitions between images. With just a few lines of code, you can integrate this functionality into your applications, enhancing user engagement and creativity. Start experimenting with the action today and explore the potential of video generation in your projects!