Enhance Your Applications with Image Generation Using DMVCreator Fyzical Actions

22 Apr 2025
Enhance Your Applications with Image Generation Using DMVCreator Fyzical Actions

In the realm of creative applications, the ability to generate and manipulate images programmatically can significantly enhance user experience. The dmvcreator/fyzical API provides a specialized Cognitive Action that allows developers to generate images with advanced features such as inpainting, custom aspect ratios, and detailed quality controls. This blog post will guide you through the capabilities of the Generate Images with Inpainting action, how to effectively use it, and provide you with a conceptual coding example to get started.

Prerequisites

To use the Cognitive Actions in the dmvcreator/fyzical API, you will need:

  • An API key for the Cognitive Actions platform.
  • Basic understanding of JSON and HTTP requests.
  • Familiarity with Python for making API calls.

Authentication is typically managed by including your API key in the request headers when you make calls to the API.

Cognitive Actions Overview

Generate Images with Inpainting

The Generate Images with Inpainting action allows developers to create images using either the 'schnell' model for quick results or the 'dev' model for detailed outputs. This action supports various customizations such as inpainting, aspect ratios, and image quality settings, providing flexibility to meet specific application needs.

Input

The required and optional fields for this action are as follows:

  • prompt (required): Descriptive text prompt for generating images. Example: "fyzical branded polo worn on physical therapist".
  • image (optional): URI of the input image for inpainting.
  • mask (optional): URI of the image mask for inpainting mode.
  • width (optional): Width of the generated image in pixels (must be between 256 and 1440).
  • height (optional): Height of the generated image in pixels (must be between 256 and 1440).
  • goFast (optional): Enable faster generation (default: false).
  • numOutputs (optional): Number of images to generate (1 to 4).
  • outputQuality (optional): Quality of saved output images (0 to 100).
  • guidanceScale (optional): Controls the guidance scale for diffusion (0 to 10).
  • numInferenceSteps (optional): Number of denoising steps for generation (1 to 50).
  • Additional fields for advanced customization (e.g., loraScale, extraLora, imageAspectRatio, etc.).

Here’s an example input JSON payload:

{
  "goFast": false,
  "prompt": "fyzical branded polo worn on physical therapist",
  "loraScale": 1,
  "numOutputs": 1,
  "guidanceScale": 3,
  "outputQuality": 80,
  "extraLoraScale": 1,
  "inferenceModel": "dev",
  "promptStrength": 0.8,
  "imageMegapixels": "1",
  "imageAspectRatio": "4:5",
  "imageOutputFormat": "png",
  "numInferenceSteps": 28
}

Output

The action returns a list of generated image URLs. Here’s an example output:

[
  "https://assets.cognitiveactions.com/invocations/deee0268-1479-44d8-abbe-e06f292e7cd6/179cb358-8c94-4e04-b662-fcf26f047c02.png"
]

Conceptual Usage Example (Python)

Below is a conceptual example of how a developer might invoke the Generate Images with Inpainting action using Python. This example focuses on structuring the input JSON payload properly.

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 = "869d4d30-8a4b-4c23-9638-461f39a19a37"  # Action ID for Generate Images with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "goFast": False,
    "prompt": "fyzical branded polo worn on physical therapist",
    "loraScale": 1,
    "numOutputs": 1,
    "guidanceScale": 3,
    "outputQuality": 80,
    "extraLoraScale": 1,
    "inferenceModel": "dev",
    "promptStrength": 0.8,
    "imageMegapixels": "1",
    "imageAspectRatio": "4:5",
    "imageOutputFormat": "png",
    "numInferenceSteps": 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 Python code snippet, replace the API key and endpoint with your own. The action_id is set for the Generate Images with Inpainting action. The input payload is structured according to the requirements outlined earlier.

Conclusion

The Generate Images with Inpainting action from the dmvcreator/fyzical API provides a robust toolkit for developers looking to enhance their applications with image generation capabilities. By leveraging customizable parameters, you can create tailored visual content that meets your specific needs. As you get familiar with these actions, consider exploring more complex use cases, such as integrating them into creative applications or automating image generation workflows. Happy coding!