Create Stunning Images Effortlessly with Realistic AI Actions

The "Realistic" service offers powerful Cognitive Actions that enable developers to generate high-quality, ultra-detailed images tailored to specific prompts. With customizable parameters and the ability to refine outputs through techniques like Img2Img, this API simplifies the image creation process, allowing for rapid and creative visual content generation. Whether you're an artist looking to enhance your portfolio, a game developer needing concept art, or a marketer seeking unique visuals for campaigns, "Realistic" provides the tools to bring your ideas to life efficiently.
Prerequisites
To get started with the Realistic Cognitive Actions, you'll need an API key for access and a basic understanding of making API calls.
Generate Realistic Image
The "Generate Realistic Image" action produces breathtaking images based on customizable prompts and various adjustable parameters. This action addresses the challenge of creating high-quality visuals quickly, making it an ideal tool for developers in creative industries.
Input Requirements
To utilize this action, you must provide a structured input schema which includes:
- Seed: An integer for random seed generation (optional).
- Width and Height: Specify the dimensions of the output image, with a maximum of 1024x768.
- Prompt: A string that describes the desired image, where you can use placeholders like
<1>,<2>, etc., for LoRA concepts. - Initial Image: A URI for an image that serves as the basis for variations (optional for Img2Img).
- Adapter Format: Choose from options like "sketch" or "seg" for additional input conditions.
- Guidance Scale: A numerical value to control the classifier-free guidance.
- LoRA Model URLs: URLs for LoRA model safetensors.
- Scheduler Type: Select from various processing schedulers.
- Prompt Strength: How strongly the prompt influences the output when an initial image is provided.
- Negative Prompt: Specify undesired elements in the output image.
- Number of Outputs: The number of images to generate (1-4).
- Inference Step Count: The number of denoising steps to process.
Expected Output
The output will be a URL linking to the generated image, ensuring you can easily retrieve and utilize the visual content.
Use Cases for this Specific Action
- Art and Illustration: Artists can leverage this action to create unique artwork or illustrations based on specific themes or concepts.
- Game Development: Developers can generate concept art or assets for characters, environments, and other game elements.
- Marketing Campaigns: Marketers can produce eye-catching visuals tailored to their branding needs, enhancing engagement with their audience.
- Content Creation: Bloggers and social media managers can quickly generate images for posts, making their content more visually appealing.
import requests
import json
# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"
action_id = "316b7a0f-4c6f-4748-904b-342ed58677b0" # Action ID for: Generate Realistic Image
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"width": 768,
"height": 768,
"prompt": "(((masterpiece))),(((bestquality))),((ultra-detailed)),(illustration),((anextremelydelicateandbeautiful)),dynamicangle,floating,(beautifuldetailedeyes),(detailedlight) (1girl), solo , floating_hair,glowingeyes,green hair,greeneyes <1>, twintails, halterdress,",
"adapterFormat": "sketch",
"guidanceScale": 3.62,
"loraModelUrls": "https://replicate.delivery/pbxt/Mf7QBwNXrehQ3k6GwMPpi8bqy0cer9x1NqogXVWylWC9l6YhA/tmp28kwa2ceclexz5tc90001zun1iy5b8x3wzip.safetensors",
"schedulerType": "K_EULER_ANCESTRAL",
"promptStrength": 0.8,
"exclusionPrompt": "multiple head, lowres, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, watermark, blurry, multiple girls, multiple faces, canvas frame, cartoon, ((multiple head)), ((bad art)), ((extra limbs)), ((b&w)), wierd colors, (((duplicate))), ((morbid)), ((mutilated)), extra fingers, mutated hands, ((poorly drawn hands)), ((poorly drawn face)), (((mutation))), (((deformed))), ((ugly)), ((bad anatomy)), (((bad proportions))), cloned face, (((disfigured))), out of frame, gross proportions, (malformed limbs), ((missing arms)), ((missing legs)), (((extra arms))), (((extra legs))), (fused fingers), (too many fingers), (((long neck))), video game, tiling, poorly drawn feet, mutated, cross-eye, body out of frame, Humpbacked, shadow, nude, naked, NSFW, bad quality, low quality, fused fingers, poorly drawn face, too many fingers",
"loraModelScales": "0.8",
"numberOfOutputs": 1,
"inferenceStepCount": 40
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json",
# Add any other required headers for the Cognitive Actions API
}
# Prepare the request body for the hypothetical execution endpoint
request_body = {
"action_id": action_id,
"inputs": payload
}
print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json=request_body
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully. Result:")
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 (non-JSON): {e.response.text}")
print("------------------------------------------------")
Conclusion
The "Realistic" Cognitive Actions empower developers to create stunning images with ease, catering to various creative needs. By utilizing customizable prompts and advanced features like Img2Img, users can generate high-quality visuals that stand out. As you explore the capabilities of this API, consider how integrating these image generation tools can enhance your projects and streamline your creative process. Start experimenting with the Realistic action today and elevate your visual content!