Create Stunning Marker-Style Sketches with the roblester/marker-illustration Actions

24 Apr 2025
Create Stunning Marker-Style Sketches with the roblester/marker-illustration Actions

In the world of digital art and image generation, the roblester/marker-illustration API provides powerful Cognitive Actions that allow developers to create unique marker-style sketches effortlessly. By leveraging a fine-tuned SDXL model and custom datasets, these actions enable precise control over image generation parameters, making it easier than ever to produce stunning artwork programmatically.

Prerequisites

Before diving into the implementation, ensure you have access to the Cognitive Actions platform and acquire your API key. Authentication typically involves passing this API key in the headers of your requests.

Here's a conceptual overview of how this might look:

Authorization: Bearer YOUR_COGNITIVE_ACTIONS_API_KEY
Content-Type: application/json

Cognitive Actions Overview

Create Marker Style Sketch

Description: Generate images in a marker-style sketch using the fine-tuned SDXL model. This action allows for stylistic influence through a custom dataset and offers control over various parameters such as prompt intensity.

Category: Image Generation

Input

The input to this action requires a JSON object structured as follows:

  • mask (optional): URI for the input mask in inpaint mode.
  • seed (optional): Integer seed value for randomization.
  • image (optional): URI of the input image for 'img2img' or 'inpaint' mode.
  • width: The width of the output image (default: 1024).
  • height: The height of the output image (default: 1024).
  • prompt: A text prompt describing the desired output image (default: "An astronaut riding a rainbow unicorn").
  • refine: The method for refining the image output (default: "no_refiner").
  • loraScale: LoRA additive scaling factor (default: 0.6).
  • loraWeights (optional): Path to LoRA weights file.
  • refineSteps (optional): Number of refinement steps for 'base_image_refiner'.
  • guidanceScale: Classifier-free guidance scale factor (default: 7.5).
  • applyWatermark: Whether to watermark the output image (default: true).
  • negativePrompt: Negative text prompt for elements to avoid in the output image.
  • promptStrength: Strength of the prompt when using 'img2img' or 'inpaint' (default: 0.8).
  • numberOfOutputs: Total number of generated image outputs (default: 1).
  • highNoiseFraction: Fraction of noise level for 'expert_ensemble_refiner' (default: 0.8).
  • schedulingAlgorithm: Algorithm used for step scheduling (default: "K_EULER").
  • numberOfInferenceSteps: Total steps for denoising the image (default: 50).
  • disableImageSafetyChecker: Option to disable the safety check for generated images (default: false).

Example Input:

{
  "seed": 5551213,
  "width": 1024,
  "height": 1024,
  "prompt": "a sketch in the style of TOK of A jazz musician playing saxophone in washington square park",
  "refine": "expert_ensemble_refiner",
  "loraScale": 0.6,
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "negativePrompt": "",
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "highNoiseFraction": 0.8,
  "schedulingAlgorithm": "K_EULER_ANCESTRAL",
  "numberOfInferenceSteps": 100
}

Output

Upon successful execution, the action typically returns an array containing URLs of the generated images. Here’s an example of the output:

[
  "https://assets.cognitiveactions.com/invocations/e16165d2-8874-4e9c-bd77-d33a8a9e3deb/74504252-d564-43fd-b772-98ed1c03c25d.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual example of how you might invoke the Create Marker Style Sketch 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 = "6d06f30f-c59c-4acf-95f7-82901a66fdf1" # Action ID for Create Marker Style Sketch

# Construct the input payload based on the action's requirements
payload = {
    "seed": 5551213,
    "width": 1024,
    "height": 1024,
    "prompt": "a sketch in the style of TOK of A jazz musician playing saxophone in washington square park",
    "refine": "expert_ensemble_refiner",
    "loraScale": 0.6,
    "guidanceScale": 7.5,
    "applyWatermark": true,
    "negativePrompt": "",
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "highNoiseFraction": 0.8,
    "schedulingAlgorithm": "K_EULER_ANCESTRAL",
    "numberOfInferenceSteps": 100
}

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}")

This Python snippet highlights how to structure your input JSON payload and call a hypothetical Cognitive Actions execution endpoint. The action ID and input details are crucial, while the endpoint URL and request structure are illustrative.

Conclusion

The roblester/marker-illustration Cognitive Actions provide a powerful toolkit for developers looking to incorporate creative image generation into their applications. From generating unique marker-style sketches to controlling the intricacies of the output, these actions can significantly elevate your digital art projects. Next steps could include experimenting with different prompts and parameters, or integrating these actions into a larger application to enhance user experiences. Happy coding!