Transform Your Photos with Cognitive Actions for Professional Portraits

24 Apr 2025
Transform Your Photos with Cognitive Actions for Professional Portraits

In the digital age, having a professional online presence is crucial, and the quality of your profile picture can make a significant difference. The editr-apps/faceshots API offers powerful Cognitive Actions designed to transform casual photographs into stunning professional portraits. These pre-built actions simplify the image enhancement process, allowing developers to integrate sophisticated image processing capabilities into their applications effortlessly.

Prerequisites

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

  • API Key: You will need an API key to access the Cognitive Actions platform. This key is usually passed in the request headers for authentication.
  • Basic Understanding of JSON: Familiarity with JSON formatting will help you construct the input payloads correctly.

Now, let’s explore the available actions.

Cognitive Actions Overview

Create Professional Portrait

Description: This action transforms a casual photograph into a professional portrait suitable for LinkedIn, focusing on business attire, a confident expression, and a neutral background. The operation involves image enhancement to highlight facial features while ensuring a polished appearance.

Category: image-processing

Input

The input for this action is defined by the following schema:

  • image (string, required): The URI of the input image to be processed.
  • width (integer, optional): The desired width of the output image in pixels (default is 640, range 512-2048).
  • height (integer, optional): The desired height of the output image in pixels (default is 640, range 512-2048).
  • prompt (string, optional): A descriptive text guiding the transformation (default is a detailed prompt about business attire and a neutral background).
  • guidanceScale (number, optional): Scale for classifier-free guidance (default is 0, range 0-10).
  • safetyChecker (boolean, optional): Filters the output for safety (enabled by default).
  • ipAdapterScale (number, optional): Scale for IP adapter operations (default is 0.8).
  • negativePrompt (string, optional): Describes what should be avoided in the output.
  • numInferenceSteps (integer, optional): Number of denoising steps applied during processing (default is 6, range 1-30).
  • controlnetConditioningScale (number, optional): Scale factor for conditioning using ControlNet (default is 0.8).

Example Input:

{
  "image": "https://replicate.delivery/pbxt/LrKm1cmtUKTLYvEQCuB240QIhinIUcVg2vEFbkM5VN56Z7OY/pexels-creation-hill-1681010.jpg",
  "width": 640,
  "height": 640,
  "prompt": "Transform this casual photo of a person img into a professional-looking portrait.",
  "guidanceScale": 0,
  "safetyChecker": true,
  "ipAdapterScale": 0.5,
  "negativePrompt": "",
  "numInferenceSteps": 6,
  "controlnetConditioningScale": 0.5
}

Output

The output of this action is a URI link to the processed professional portrait image.

Example Output:

https://assets.cognitiveactions.com/invocations/fc09e55a-9aad-4c4e-a77a-dcc988ee1d3a/8648e93b-23b2-4573-b701-97ed7390d670.jpg

Conceptual Usage Example (Python)

Here’s how you might call the Create Professional Portrait action using a hypothetical Cognitive Actions endpoint in 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 = "88651707-1a14-4a69-8f69-28b3dad890f5" # Action ID for Create Professional Portrait

# Construct the input payload based on the action's requirements
payload = {
    "image": "https://replicate.delivery/pbxt/LrKm1cmtUKTLYvEQCuB240QIhinIUcVg2vEFbkM5VN56Z7OY/pexels-creation-hill-1681010.jpg",
    "width": 640,
    "height": 640,
    "prompt": "Transform this casual photo of a person img into a professional-looking portrait.",
    "guidanceScale": 0,
    "safetyChecker": True,
    "ipAdapterScale": 0.5,
    "negativePrompt": "",
    "numInferenceSteps": 6,
    "controlnetConditioningScale": 0.5
}

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 example, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id corresponds to the Create Professional Portrait action, and the payload contains the required and optional parameters for the image processing task.

Conclusion

The editr-apps/faceshots Cognitive Actions provide an effective and straightforward way to enhance casual photographs into professional portraits. Whether for personal branding or business use, integrating these capabilities can significantly elevate the quality of your application's image processing features. Start experimenting with these actions to transform your images today!