Create Stunning Images with the victorbarroz/victorbasemodelo Cognitive Actions

22 Apr 2025
Create Stunning Images with the victorbarroz/victorbasemodelo Cognitive Actions

In the world of artificial intelligence, the ability to generate and manipulate images has opened up exciting possibilities for developers. The victorbarroz/victorbasemodelo API provides a powerful Cognitive Action that allows you to create realistic images using advanced inpainting techniques. This action not only simplifies the image generation process but also offers extensive customization options, enabling you to produce high-quality visuals tailored to your needs.

Prerequisites

Before diving into the integration of Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic familiarity with RESTful APIs and JSON data structures.
  • A Python environment set up for making HTTP requests.

Authentication typically involves passing your API key in the headers of your requests, ensuring secure access to the Cognitive Actions service.

Cognitive Actions Overview

Generate Image with Inpainting

The Generate Image with Inpainting action creates a detailed and realistic image based on a descriptive prompt and optional parameters for customization. This action is categorized under image-generation.

Input

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

{
  "prompt": "string (required)",
  "image": "string (optional, uri)",
  "mask": "string (optional, uri)",
  "model": "string (optional, default: 'dev')",
  "width": "integer (optional)",
  "height": "integer (optional)",
  "loraScale": "number (optional, default: 1)",
  "outputCount": "integer (optional, default: 1)",
  "enableFastMode": "boolean (optional, default: false)",
  "imageResolution": "string (optional, default: '1')",
  "imageAspectRatio": "string (optional, default: '1:1')",
  "imageOutputFormat": "string (optional, default: 'webp')",
  "imageOutputQuality": "integer (optional, default: 80)",
  "additionalLoraScale": "number (optional, default: 1)",
  "imagePromptStrength": "number (optional, default: 0.8)",
  "inferenceStepsCount": "integer (optional, default: 28)",
  "diffusionGuidanceScale": "number (optional, default: 3)"
}

Example Input:

{
  "image": "https://replicate.delivery/pbxt/Mmkcgt2djZZpjd7Jxyb1GLVT4GmIDHaAfYTtRjqWkX5LNhqc/ea3fee6ce7c40900baf7fe23b0793567.jpg",
  "model": "dev",
  "prompt": "victorbarroz / victorbasemodelo\n\nphoto realistic cinema, skin pores are very clear in the photo\nlight skin short beard, short hair\n\nClose-up profile portrait of a handsome man with short hair shaved on the sides and neatly styled on top. He has a well-groomed beard and slightly wet hair partially falling over his forehead. He wears round reflective sunglasses and has a thoughtful gaze looking into the distance. The image is in dramatic black and white, with strong directional sunlight creating deep shadows and highlights on his skin and hair, giving it a cinematic, high-contrast feel. The skin texture is realistic, and the glow on his shoulder suggests moisture, like sweat or water. The overall aesthetic is stylish and sensual, evoking a summer or beach vibe, with a confident and mysterious expression. The photography conveys a mix of masculinity, mystery, and elegance.\n\n",
  "loraScale": 1,
  "outputCount": 1,
  "enableFastMode": false,
  "imageResolution": "1",
  "imageAspectRatio": "3:4",
  "imageOutputFormat": "webp",
  "imageOutputQuality": 100,
  "additionalLoraScale": 1,
  "imagePromptStrength": 0.8,
  "inferenceStepsCount": 28,
  "diffusionGuidanceScale": 3
}

Output

Upon successful execution, the action returns a URL to the generated image:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/850daccf-1439-4017-8895-db76d6d45d5a/0e42ae94-057d-4c16-8ff8-ebc80b95c856.webp"
]

Conceptual Usage Example (Python)

Here’s a conceptual example of how you might call this 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 = "11060d4c-73b6-47c4-abb2-e65a63cdc339" # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "image": "https://replicate.delivery/pbxt/Mmkcgt2djZZpjd7Jxyb1GLVT4GmIDHaAfYTtRjqWkX5LNhqc/ea3fee6ce7c40900baf7fe23b0793567.jpg",
    "model": "dev",
    "prompt": "victorbarroz / victorbasemodelo\n\nphoto realistic cinema, skin pores are very clear in the photo...",
    "loraScale": 1,
    "outputCount": 1,
    "enableFastMode": false,
    "imageResolution": "1",
    "imageAspectRatio": "3:4",
    "imageOutputFormat": "webp",
    "imageOutputQuality": 100,
    "additionalLoraScale": 1,
    "imagePromptStrength": 0.8,
    "inferenceStepsCount": 28,
    "diffusionGuidanceScale": 3
}

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 replace the placeholder API key and endpoint with your actual values. The payload variable is structured according to the input schema required by the action.

Conclusion

Integrating the Generate Image with Inpainting action from the victorbarroz/victorbasemodelo API can significantly enhance your application by providing high-quality image generation capabilities. With the flexibility to customize various parameters, developers can create stunning visuals tailored to specific requirements.

Consider exploring additional use cases, such as creating marketing materials, enhancing user-generated content, or even integrating it into art applications. The possibilities are endless, and with this powerful tool at your disposal, you can bring your creative visions to life!