Create Stunning Female Portraits with the melch321/mymc Cognitive Actions

25 Apr 2025
Create Stunning Female Portraits with the melch321/mymc Cognitive Actions

Integrating image generation capabilities into your applications can significantly enhance user experience and creativity. The melch321/mymc spec provides a powerful Cognitive Action that allows developers to create dynamic female portrait scenes, complete with realistic lighting and effects. By leveraging pre-built actions, you can focus on building your application without getting bogged down in the complexities of image processing.

Prerequisites

To get started with the Cognitive Actions for melch321/mymc, you’ll need to have:

  • An API key for accessing the Cognitive Actions platform.
  • Basic knowledge of JSON structure and HTTP requests.

Authentication typically involves passing your API key in the request headers, allowing you to securely access the service.

Cognitive Actions Overview

Create Dynamic Female Portrait Scene

The Create Dynamic Female Portrait Scene action generates a vibrant scene around a female portrait by using image inpainting and transformation techniques. This action can produce stunning visuals that incorporate natural lighting and dynamic elements to enhance realism.

Input

The input schema for this action requires the following fields:

  • prompt (string, required): A text prompt describing the scene to be generated.
  • mask (string, optional): A URI for an image mask for inpainting.
  • image (string, optional): A URI for an input image, if inpainting is used.
  • model (string, optional): The model to use for image generation (dev or schnell).
  • width (integer, optional): The width of the generated image, applicable in custom aspect ratios.
  • height (integer, optional): The height of the generated image, applicable in custom aspect ratios.
  • goFast (boolean, optional): Enable faster predictions.
  • numOutputs (integer, optional): Number of image outputs to generate (1 to 4).
  • aspectRatio (string, optional): The aspect ratio for the image (various formats).
  • outputFormat (string, optional): The format of output images (e.g., webp, jpg, png).
  • guidanceScale (number, optional): Scale for image generation guiding.
  • outputQuality (integer, optional): Quality setting for output images.
  • promptStrength (number, optional): Intensity of the prompt when using image inputs.
  • numInferenceSteps (integer, optional): Total denoising steps for image generation.

Here’s an example input payload:

{
  "model": "dev",
  "goFast": false,
  "prompt": "Transformez TOK en une icône des réseaux sociaux avec une photo captivante, digne des plus grandes instagrameuses. Imaginez une scène vibrante où la lumière naturelle du Sunset caresse mon visage, accentuant mon sourire radieux. Des éléments dynamiques, comme des flocons de neige qui tombent doucement autour de moi, ajoutent une de douceur au montagnes enneigées. La caméra effectue un zoom avant fluide, capturant chaque détail de mon look stylé pour les sports d'hivers. Un léger mouvement de cheveux au vent complète cette ambiance glamour, créant une image mémorable et inspirante.",
  "numOutputs": 3,
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 3,
  "outputQuality": 80,
  "promptStrength": 0.8,
  "mainLoraIntensity": 1,
  "numInferenceSteps": 28,
  "approximateMegapixels": "1",
  "additionalLoraIntensity": 1
}

Output

The output from this action is an array of URLs pointing to the generated images. Here’s an example of the expected output:

[
  "https://assets.cognitiveactions.com/invocations/91e4a6e7-38db-4f79-9a7f-75e74d776c44/62e4fa99-452f-4599-ac6a-57260737a562.webp",
  "https://assets.cognitiveactions.com/invocations/91e4a6e7-38db-4f79-9a7f-75e74d776c44/a72efae9-a77a-46d0-895e-d419b7c28c01.webp",
  "https://assets.cognitiveactions.com/invocations/91e4a6e7-38db-4f79-9a7f-75e74d776c44/5eafe8c1-35e7-4f22-a9e0-e69b0d43c8a7.webp"
]

Conceptual Usage Example (Python)

Here’s how you might call the Create Dynamic Female Portrait Scene 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 = "43f3c5ae-39be-491a-aa15-d72a8a9cef73" # Action ID for Create Dynamic Female Portrait Scene

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "goFast": False,
    "prompt": "Transformez TOK en une icône des réseaux sociaux avec une photo captivante, digne des plus grandes instagrameuses. Imaginez une scène vibrante où la lumière naturelle du Sunset caresse mon visage, accentuant mon sourire radieux. Des éléments dynamiques, comme des flocons de neige qui tombent doucement autour de moi, ajoutent une de douceur au montagnes enneigées. La caméra effectue un zoom avant fluide, capturant chaque détail de mon look stylé pour les sports d'hivers. Un léger mouvement de cheveux au vent complète cette ambiance glamour, créant une image mémorable et inspirante.",
    "numOutputs": 3,
    "aspectRatio": "1:1",
    "outputFormat": "webp",
    "guidanceScale": 3,
    "outputQuality": 80,
    "promptStrength": 0.8,
    "mainLoraIntensity": 1,
    "numInferenceSteps": 28,
    "approximateMegapixels": "1",
    "additionalLoraIntensity": 1
}

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 is specified to indicate which Cognitive Action you intend to execute, and the input payload is structured according to the requirements of the action.

Conclusion

The melch321/mymc spec offers a unique opportunity to integrate dynamic image generation capabilities into your applications. By leveraging the Create Dynamic Female Portrait Scene action, developers can create visually stunning and engaging content with minimal effort. Consider exploring additional use cases, such as enhancing user-generated content or creating promotional materials, to maximize the potential of these Cognitive Actions.