Generate Custom Images Effortlessly with saeed3e/generate_my_photos Cognitive Actions

23 Apr 2025
Generate Custom Images Effortlessly with saeed3e/generate_my_photos Cognitive Actions

In today's digital landscape, generating unique images tailored to specific prompts can enhance creativity and productivity. The saeed3e/generate_my_photos API provides a powerful set of Cognitive Actions that allow developers to generate customized images based on detailed input prompts and various settings. With capabilities such as image inpainting, fast generation modes, and LoRA adjustments, this API enables users to create high-quality images quickly and effectively.

Prerequisites

Before you can start using the Cognitive Actions, make sure you have the following:

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • Basic knowledge of JSON and HTTP requests.

Authentication typically involves passing the API key in the request headers to ensure secure access to the Cognitive Actions.

Cognitive Actions Overview

Generate My Photos

Description: This action generates customized images based on input prompts and configurable settings like aspect ratio, model type, and image quality. It supports image inpainting, fast generation modes, and LoRA adjustments for detailed results.

Category: Image Generation

Input

The input to this action is a JSON object with several properties. Below are the required and optional fields:

  • Required:
    • prompt: (string) Text prompt to guide the image generation.
  • Optional:
    • mask: (string) Image mask for inpainting mode.
    • seed: (integer) Random seed for reproducibility.
    • image: (string) Input image for image-to-image or inpainting mode.
    • model: (string) Model for inference (default: "dev").
    • width: (integer) Width of the generated image (256-1440).
    • height: (integer) Height of the generated image (256-1440).
    • loraScale: (number) Strength of the primary LoRA application (default: 1).
    • megapixels: (string) Approximate megapixel count ("1" or "0.25").
    • aspectRatio: (string) Aspect ratio for the image (default: "1:1").
    • loadWeights: (string) Load LoRA weights from supported sources.
    • outputFormat: (string) File format for saving images (default: "webp").
    • guidanceScale: (number) Scale for guiding the diffusion process (default: 3).
    • outputQuality: (integer) Quality when saving images (0-100, default: 80).
    • enableFastMode: (boolean) Enable faster predictions (default: false).
    • numberOfOutputs: (integer) Number of output images (1-4).
    • inferenceStepCount: (integer) Total denoising steps for image generation (default: 28).
    • additionalLora: (string) Load additional LoRA weights.
    • additionalLoraScale: (number) Control strength of additional LoRA application.
    • disableSafetyChecker: (boolean) Disable the safety checker (default: false).

Example Input:

{
  "model": "dev",
  "prompt": "my photos show me as a professional software engineer, sitting at a modern workspace with multiple monitors displaying code and system diagrams.",
  "loraScale": 1,
  "megapixels": "1",
  "aspectRatio": "16:9",
  "outputFormat": "jpg",
  "guidanceScale": 3,
  "outputQuality": 80,
  "enableFastMode": false,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "inferenceStepCount": 28,
  "additionalLoraScale": 1
}

Output

The action typically returns a JSON array containing the URLs of the generated images. For example:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/f7f5ca78-b007-43a1-b437-06bcba3fefab/959bc828-aa17-4357-8d85-7a0aa9fc2a51.jpg"
]

Conceptual Usage Example (Python)

Here’s how you can call the Generate My Photos 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 = "e40f838c-aa1f-415e-ac67-2b8640acfc25" # Action ID for Generate My Photos

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "my photos show me as a professional software engineer, sitting at a modern workspace with multiple monitors displaying code and system diagrams.",
    "loraScale": 1,
    "megapixels": "1",
    "aspectRatio": "16:9",
    "outputFormat": "jpg",
    "guidanceScale": 3,
    "outputQuality": 80,
    "enableFastMode": False,
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "inferenceStepCount": 28,
    "additionalLoraScale": 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 code snippet, you'll need to replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID for generating photos is set, and the input payload is structured according to the action's requirements. The hypothetical endpoint URL is used to send a POST request to execute the action.

Conclusion

The saeed3e/generate_my_photos Cognitive Actions offer a powerful way to generate custom images based on detailed prompts. By leveraging features like image inpainting and various adjustable settings, developers can create high-quality images tailored to specific needs.

Explore this API further to unlock its full potential, and consider integrating it into your applications for enhanced visual content generation!