Create Stunning Images with the m-mohamed/ghost-shell-flux Cognitive Actions
The m-mohamed/ghost-shell-flux provides a powerful set of Cognitive Actions designed for developers interested in generating and customizing images using advanced techniques like inpainting. This specification allows you to tap into the capabilities of image generation models, offering flexibility for both detailed results and faster outputs. By leveraging these pre-built actions, you can enhance your applications with sophisticated image generation features without needing to build complex algorithms from scratch.
Prerequisites
To get started with the Cognitive Actions in the m-mohamed/ghost-shell-flux spec, you will need an API key for authentication purposes. Typically, this involves passing your API key in the request headers to authenticate your requests.
Example Authentication Header:
Authorization: Bearer YOUR_COGNITIVE_ACTIONS_API_KEY
Cognitive Actions Overview
Generate Image with Inpainting
Purpose:
This action generates an image based on a provided text prompt while optionally applying inpainting techniques. It allows for various model modes, including a detailed 'dev' mode and a faster 'schnell' mode, along with the ability to customize several aspects of the generated image.
Category: Image Generation
Input
The input for this action follows a defined schema, which includes several optional and required fields:
- prompt (required): Text prompt for image generation.
- mask: URI of the image mask for inpainting.
- seed: Integer for random number generation.
- model: Choose between 'dev' and 'schnell'.
- width: Width of the generated image.
- height: Height of the generated image.
- goFast: Enables the optimized speed model.
- imageFormat: Format of the output image (e.g., webp, jpg, png).
- imageQuality: Quality level of the output image.
- outputQuantity: Number of images to generate (1-4).
- imageAspectRatio: Aspect ratio settings.
- inferenceStepCount: Number of denoising iterations.
Example Input
{
"model": "dev",
"prompt": "PPTXMSTR Create a landscape drawing of bustling city in the art style of the ghost in the shell anime",
"imageFormat": "webp",
"imageQuality": 90,
"loraIntensity": 1,
"outputQuantity": 1,
"promptIntensity": 0.8,
"imageAspectRatio": "1:1",
"guidanceIntensity": 3.5,
"inferenceStepCount": 28,
"additionalLoraIntensity": 1
}
Output
The output of the action typically returns a URL pointing to the generated image.
Example Output
[
"https://assets.cognitiveactions.com/invocations/b5c03a7b-dfb7-4cd9-8a9a-de3e007ed05d/2694e6fd-b08f-4e57-ad3a-17f78168f0a8.webp"
]
Conceptual Usage Example (Python)
Here's a conceptual example of how to call the Generate Image with Inpainting 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 = "106672e8-6076-4a04-afd9-fb616a3a514c" # Action ID for Generate Image with Inpainting
# Construct the input payload based on the action's requirements
payload = {
"model": "dev",
"prompt": "PPTXMSTR Create a landscape drawing of bustling city in the art style of the ghost in the shell anime",
"imageFormat": "webp",
"imageQuality": 90,
"loraIntensity": 1,
"outputQuantity": 1,
"promptIntensity": 0.8,
"imageAspectRatio": "1:1",
"guidanceIntensity": 3.5,
"inferenceStepCount": 28,
"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 the placeholders with your actual API key and endpoint. The action ID is set for the "Generate Image with Inpainting" action, and the input payload is structured to meet the action's requirements. The endpoint URL and request structure are illustrative and may vary based on actual implementation.
Conclusion
The m-mohamed/ghost-shell-flux Cognitive Actions offer a robust solution for developers looking to integrate advanced image generation capabilities into their applications. By using the "Generate Image with Inpainting" action, you can create stunning visuals tailored to your specific needs. Explore further by experimenting with different parameters and combining actions to unlock new creative possibilities!