Create Stunning Images from Text Prompts Using Hermanoscorrea

In today's digital landscape, the demand for high-quality, visually appealing content is ever-growing. The Hermanoscorrea service offers a powerful Cognitive Action that enables developers to generate unique images from text prompts, complete with inpainting capabilities. This means you can not only create images based on descriptions but also customize them with specific features such as aspect ratios, sizes, and resolutions. This flexibility allows for tailored visual content that meets specific needs in various applications, whether for marketing, digital art, or user-generated content platforms.
Imagine being able to create a breathtaking vineyard scene, as described in a prompt, with just a few lines of text. The speed and ease with which you can generate these images can significantly enhance your project's visual storytelling, making it a go-to solution for developers looking to enrich their applications with custom imagery.
Prerequisites
To get started with Hermanoscorrea, you'll need a Cognitive Actions API key and a basic understanding of how to make API calls.
Generate Image from Prompt with Inpainting
The Generate Image from Prompt with Inpainting action allows developers to create images based on detailed text prompts while offering the option to refine those images through inpainting. This feature is especially useful for creating customized visuals that align closely with user specifications.
Purpose
This action solves the problem of generating unique images that can be tailored to specific narratives or themes. By using descriptive prompts, you can instruct the model to produce images that reflect intricate details, ensuring that the visuals resonate with the intended message.
Input Requirements
The input for this action requires a structured JSON object that includes at least the following parameters:
- prompt: A detailed description guiding the image generation (required).
- mask: An optional URI for an image mask used in inpainting mode.
- image: An optional URI of the input image for image-to-image or inpainting mode.
- width and height: Specify the dimensions of the generated image (optional, only effective when aspect_ratio is set to 'custom').
- imageFormat: The desired output format (e.g., jpg, webp).
- outputCount: Number of images to generate (1 to 4).
Expected Output
The output will be a list of URIs pointing to the generated images, allowing you to easily access and utilize the visuals in your applications.
Use Cases for this specific action
- Marketing Campaigns: Create eye-catching visuals that align with specific themes or products.
- Content Creation: Generate unique images for blogs, articles, or social media posts based on descriptive narratives.
- Game Development: Develop character or environment art based on textual descriptions, enhancing the immersive experience for players.
- Personal Projects: Bring your creative visions to life by generating custom art pieces from your imagination.
```python
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 = "5472ac37-d414-42c7-8e0a-d5b7a5f02bad" # Action ID for: Generate Image from Prompt with Inpainting
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"width": 1440,
"height": 1440,
"prompt": "SCL, a distinguished man with a strong presence, is crouching in a serene vineyard at sunset, his gaze fixed on the distant horizon. His posture is balanced and grounded, with both feet firmly on the ground and his knees bent. His elbows rest on his thighs, and his hands are relaxed, fingers gently intertwined. His expression is calm and contemplative, conveying a sense of deep thought and connection with nature.\n\nThe camera is positioned farther away, capturing a wider shot that includes more of the surrounding vineyard. The slightly low angle remains, but now SCL appears smaller within the vast landscape, emphasizing the openness of the scene and his connection to the environment. This framing allows for a greater sense of scale, showcasing the vineyard stretching toward the horizon.\n\nSCL has a Caucasian phenotype, with well-defined and symmetrical facial features. His ectomorphic body type with mesomorphic tendencies gives him a lean yet firm build. His elongated face has prominent cheekbones, a defined jawline, and a slightly angular chin. His skin is fair with a slightly tanned tone. His dark, almond-shaped eyes convey a calm yet confident expression. His thick, slightly wavy dark hair is casually styled with a natural part. He has long, thick sideburns blending into a light beard on his cheeks. His full, moderately arched eyebrows complement his straight, well-proportioned nose. His medium-thickness lips carry a neutral yet subtly smiling expression.\n\nSCL wears a rugged yet practical outfit, ideal for the outdoors. He dons a long-sleeved button-up shirt in a light khaki or beige tone, made from a durable fabric like cotton or a linen blend. The shirt is slightly wrinkled, adding to its natural and functional appearance. His blue denim jeans have a classic, comfortable fit, allowing ease of movement. He completes the look with sturdy work boots, likely made of leather or rubber, designed for rough terrains. His attire reflects practicality and comfort, suited for someone who spends time in nature.\n\nBackground Modified: Instead of an open field with cattle, SCL is surrounded by a breathtaking vineyard during a golden sunset. Rows of lush grapevines stretch toward the horizon, their leaves glowing under the warm hues of the setting sun. The sky is a mesmerizing blend of soft pinks, oranges, and purples, casting a tranquil and picturesque atmosphere over the scene. The wider shot enhances the depth of the setting, making SCL feel immersed in the landscape. The shallow depth of field ensures that while SCL remains in sharp focus, the vineyard and sky blend seamlessly into a cinematic and immersive composition.",
"imageFormat": "jpg",
"outputCount": 2,
"mainLoraScale": 1,
"inferenceModel": "dev",
"imageMegapixels": "1",
"imageAspectRatio": "1:1",
"speedOptimization": false,
"imageOutputQuality": 100,
"inferenceStepCount": 28,
"additionalLoraScale": 1,
"imagePromptStrength": 1,
"diffusionGuidanceScale": 3.95
}
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 Hermanoscorrea service's image generation capabilities provide developers with a powerful tool to create stunning visuals from text prompts. With customizable features and the ability to generate multiple images at once, this action opens up a world of possibilities for enhancing user engagement and storytelling. Whether you're in marketing, game development, or content creation, leveraging this technology can elevate your projects to new heights. Explore the potential of image generation today and transform your ideas into visual reality!