Create Stunning Visuals Effortlessly with Geraldine Image Generation

Geraldine offers a powerful suite of Cognitive Actions designed to revolutionize the way developers generate high-quality images. With its advanced features, you can create visually striking images tailored to your specifications, including prompts, aspect ratios, and various model options. Whether you're working on creative projects, marketing materials, or enhancing user experiences, Geraldine simplifies the image generation process, enabling faster and more efficient workflows. This API is particularly beneficial for developers looking to integrate sophisticated image generation capabilities into their applications without needing extensive graphics design skills.
Prerequisites
To get started with Geraldine, you’ll need a Cognitive Actions API key and a basic understanding of making API calls. This will allow you to harness the full potential of the image generation capabilities.
Generate Enhanced Image
The "Generate Enhanced Image" action allows you to create high-quality images based on specified parameters. It addresses the need for custom visual content, enabling developers to produce images that meet specific creative requirements.
- Input Requirements: The action accepts a variety of inputs, with the primary requirement being a text
promptthat describes the desired image. Additional optional parameters include:image: URL of an input image for transformations.mask: URI to an image mask for inpainting.widthandheight: Dimensions for the generated image.numOutputs: Number of images to generate (1 to 4).guidanceScale,loraScale, and others for fine-tuning output.
- Expected Output: The action returns a URL to the generated image, which will be a high-quality visual based on the provided specifications.
Use Cases for this specific action:
- Creative Industries: Artists and designers can use this feature to rapidly prototype and generate visuals for campaigns, social media posts, and more, saving time and resources.
- E-commerce: Businesses can create product images with specific attributes or styles, enhancing their online presence and attracting more customers.
- Gaming and Animation: Developers can generate character designs or backgrounds, allowing for quick iterations and unique artistic expressions.
- Personalization: Applications can offer users the ability to create custom images based on their preferences, enhancing user engagement.
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 = "9a9b9f3b-da63-420c-862e-ff275a6a1583" # Action ID for: Generate Enhanced Image
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"image": "https://replicate.delivery/pbxt/Ln4ejYtnSlm7ko9KplV5ZtWUnpg9P2QdKd0kKO0OQMOnGoDe/France_Tori_Black_Brown_haired_Dress_Red_Model_576043_790x1024.jpg",
"height": 1440,
"prompt": "A hyper-realistic portrait of GERALDINEAI, a highly skilled female doctor, wearing a stunning, form-fitting red dress. She stands confidently with the Eiffel Tower visible in the background, symbolizing grace and professionalism. Her long hair cascades over her shoulders, perfectly styled, and her expression is calm yet powerful, exuding both intelligence and elegance. The red dress contrasts beautifully with the Parisian skyline. Soft, natural lighting accentuates the rich texture of her dress and the fine details of her face, from the subtle shine of her lipstick to the reflections in her eyes. The mood is sophisticated and striking, with incredible attention to detail, photorealistic, hd quality ",
"loraScale": 1,
"numOutputs": 1,
"guidanceScale": 3.5,
"outputQuality": 100,
"extraLoraScale": 1,
"inferenceModel": "dev",
"promptStrength": 0.8,
"imageAspectRatio": "9:16",
"imageOutputFormat": "jpg",
"numInferenceSteps": 28
}
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
Geraldine's image generation capabilities empower developers to create stunning visuals with ease, unlocking new possibilities for creativity and innovation. By utilizing the "Generate Enhanced Image" action, you can streamline your workflows and enhance the visual appeal of your projects. Consider integrating Geraldine into your applications to elevate your image generation processes and meet the growing demand for high-quality visual content.