Generate High-Quality Corporate Headshots with the hirensyd/headshots_trainer Cognitive Actions

Creating professional headshots has never been easier, thanks to the hirensyd/headshots_trainer API. This powerful tool allows developers to generate dynamic, high-quality corporate headshots using advanced image processing technologies. With options for customization—including image dimensions, output quality, and prompt strength—users can achieve photorealistic results tailored to their specifications. In this article, we'll walk through how to integrate the "Generate Professional Headshot" action into your applications.
Prerequisites
Before you start using 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 generally involves passing your API key in the request headers for secure access to the service.
Cognitive Actions Overview
Generate Professional Headshot
The Generate Professional Headshot action allows you to create high-quality corporate headshots using image inpainting and transformation techniques. This action supports various customization options to ensure your results meet professional standards.
Input
The input for this action requires the following fields:
- prompt (required): A descriptive text guiding the generation of the image.
- mask (optional): A URI defining the image mask for inpainting mode.
- seed (optional): An integer to set a specific random seed for reproducibility.
- image (optional): A URI for the input image if using image-to-image transformation.
- width (optional): Specifies the generated image width (256 to 1440).
- height (optional): Specifies the generated image height (256 to 1440).
- goFast (optional): A boolean for enabling faster predictions.
- loraScale (optional): A number to adjust the main LoRA application strength.
- fileFormat (optional): The output image format (webp, jpg, png).
- outputCount (optional): The number of images to generate (1 to 4).
- inferenceModel (optional): Choose between "dev" and "schnell" for model performance.
- guidanceScale (optional): Influences the diffusion process guidance scale.
- outputQuality (optional): Sets the quality of the output image (0 to 100).
- additionalLoraScale (optional): Defines strength for additional LoRA application.
- inferenceStepsCount (optional): Number of denoising steps (1 to 50).
Example Input:
{
"prompt": "create a dynamic professional corporate headshot of hp, sharp facial features, confident smile, professional attire with navy blue suit, crisp white shirt, soft rembrandt lighting, shallow depth of field, shot with Canon EOS R5, 85mm F/1.4 lens, studio setting with subtle gray gradient background, professional color grading, high end retouching, high resolution, photorealistic quality, professional photography, sharp focus on eyes, perfect exposure, natural skin texture, cinematic color grading, 8k, hyperrealistic, award winning professional business portrait, centered composition --ar 3:4 --v 5 --s 750",
"loraScale": 1,
"fileFormat": "webp",
"outputCount": 1,
"guidanceScale": 3.5,
"outputQuality": 90,
"inferenceModel": "dev",
"promptStrength": 0.8,
"imageAspectRatio": "1:1",
"additionalLoraScale": 1,
"inferenceStepsCount": 28
}
Output
The action typically returns a URL pointing to the generated headshot image.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/b3c638fb-f551-49b5-be2e-53adffbec90a/d12da8c0-d03b-430d-95ce-da6c8088eb8c.webp"
]
Conceptual Usage Example (Python)
Here's a conceptual Python code snippet that demonstrates how to call the "Generate Professional Headshot" 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 = "1fb93d7c-41bb-4341-8df8-2f65d30abb6e" # Action ID for Generate Professional Headshot
# Construct the input payload based on the action's requirements
payload = {
"prompt": "create a dynamic professional corporate headshot of hp, sharp facial features, confident smile, professional attire with navy blue suit, crisp white shirt, soft rembrandt lighting, shallow depth of field, shot with Canon EOS R5, 85mm F/1.4 lens, studio setting with subtle gray gradient background, professional color grading, high end retouching, high resolution, photorealistic quality, professional photography, sharp focus on eyes, perfect exposure, natural skin texture, cinematic color grading, 8k, hyperrealistic, award winning professional business portrait, centered composition --ar 3:4 --v 5 --s 750",
"loraScale": 1,
"fileFormat": "webp",
"outputCount": 1,
"guidanceScale": 3.5,
"outputQuality": 90,
"inferenceModel": "dev",
"promptStrength": 0.8,
"imageAspectRatio": "1:1",
"additionalLoraScale": 1,
"inferenceStepsCount": 28
}
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, you'll need to replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID is set to correspond to the "Generate Professional Headshot" action. The input JSON structure is created based on the example input provided above.
Conclusion
The hirensyd/headshots_trainer Cognitive Action provides developers with a powerful way to generate professional headshots effortlessly. By leveraging advanced image processing technologies, you can create stunning visuals tailored to your specifications. Whether for corporate use, personal branding, or artistic projects, integrating this action into your applications opens up new possibilities. Explore the potential of generating high-quality images and consider trying out different customization options to see what works best for your needs!