Create Stunning Basketball Player Portraits with mklef80/darnell-williams Cognitive Actions

Cognitive Actions provide a powerful way to leverage advanced image generation capabilities for developers looking to create visually compelling content. The mklef80/darnell-williams spec offers a specialized action to generate high-contrast portraits of basketball player Darnell Williams. This action allows for various configurations, enabling developers to optimize for either speed or quality, making it an excellent addition to any application focusing on image processing and generation.
Prerequisites
Before you start integrating the Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform.
- Basic familiarity with making HTTP requests and handling JSON data.
- A suitable programming environment set up for executing API calls (e.g., Python with the
requestslibrary).
Authentication typically involves passing your API key in the request headers.
Cognitive Actions Overview
Generate Basketball Player Portrait
Description:
This action generates a high-contrast, desaturated portrait of basketball player Darnell Williams. It includes configurable options for image inpainting, resolution adjustments, and model selection for either speed or quality optimization.
Category: Image Generation
Input
- Required:
prompt: A detailed description of the portrait to generate.
- Optional:
mask: Image mask for inpainting mode. Overrides width and height.seed: Random seed for reproducibility.image: Input image for image-to-image or inpainting mode. Overrides width and height.model: Selects the inference model (devorschnell).width: Width of the generated image (must be a multiple of 16).height: Height of the generated image (must be a multiple of 16).goFast: Enables faster predictions using an optimized model.aspectRatio: Specifies the aspect ratio of the generated image.- Additional parameters for output format, quality, guidance scale, LoRA weights, etc.
Example Input:
{
"model": "dev",
"prompt": "American shot portrait of a professional basketball player, Darnell-Williams, 46 years old, African-American, 6'7\" (2.01m) tall. He looks directly at the camera with a confident, determined, and friendly expression. He holds a basketball at arm's length in front of his chest, pointing towards the camera. He's wearing a black basketball uniform. The scene takes place in a studio with a white background. The lighting is dramatic, creating strong contrasts on his face and body. The image style is high-contrast and desaturated, emphasizing the interplay of light and shadow. The composition is centered on the player, capturing his imposing stature and professional attitude.",
"aspectRatio": "1:1",
"outputFormat": "webp",
"guidanceScale": 3.5,
"mainLoraScale": 1,
"outputQuality": 90,
"promptStrength": 0.8,
"numberOfOutputs": 1,
"additionalLoraScale": 1,
"numberOfInferenceSteps": 28
}
Output
The action typically returns a URL to the generated image in the specified output format.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/9601172f-8641-453e-accc-6221e7af73f7/fbcdff6e-6b70-449f-ac4e-4469990249c3.webp"
]
Conceptual Usage Example (Python)
Here’s how you might implement the above action using a hypothetical Cognitive Actions execution endpoint:
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 = "915a9941-9284-4b76-899f-73204797fd5d" # Action ID for Generate Basketball Player Portrait
# Construct the input payload based on the action's requirements
payload = {
"model": "dev",
"prompt": "American shot portrait of a professional basketball player, Darnell-Williams, 46 years old, African-American, 6'7\" (2.01m) tall. He looks directly at the camera with a confident, determined, and friendly expression. He holds a basketball at arm's length in front of his chest, pointing towards the camera. He's wearing a black basketball uniform. The scene takes place in a studio with a white background. The lighting is dramatic, creating strong contrasts on his face and body. The image style is high-contrast and desaturated, emphasizing the interplay of light and shadow. The composition is centered on the player, capturing his imposing stature and professional attitude.",
"aspectRatio": "1:1",
"outputFormat": "webp",
"guidanceScale": 3.5,
"mainLoraScale": 1,
"outputQuality": 90,
"promptStrength": 0.8,
"numberOfOutputs": 1,
"additionalLoraScale": 1,
"numberOfInferenceSteps": 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 example, replace the placeholder API key and endpoint with actual values. The payload is structured according to the action's input schema, including the detailed prompt for the image generation.
Conclusion
The mklef80/darnell-williams Cognitive Actions provide a robust toolset for generating stunning basketball player portraits. By leveraging the flexibility of input parameters and model selection, developers can create tailored images that meet specific needs in applications. Whether for marketing, game development, or content creation, these actions can enhance visual storytelling and engagement. Start integrating today and explore the possibilities of image generation!