Create Stunning Edward Hopper-Style Images with Cognitive Actions
In the world of art and technology, merging creativity with advanced algorithms has opened new avenues for artistic expression. The llpfromparis/ewardhopper Cognitive Actions provide developers with the ability to generate detailed images that mimic the iconic painting style of Edward Hopper. By utilizing these pre-built actions, you can create stunning visuals tailored to specific parameters, ensuring both flexibility and reproducibility in your projects.
Prerequisites
Before diving into the integration of these Cognitive Actions, ensure you have an API key for accessing the Cognitive Actions platform. This key is typically passed in the headers of your HTTP requests for authentication purposes.
Cognitive Actions Overview
Generate Detailed Images with Edward Hopper Style
This action allows you to generate highly detailed images that replicate Edward Hopper's realistic painting style. You can customize various parameters to create images that are not only striking but also tailored to your specific requirements.
Input
The input for this action requires the following fields:
- prompt (required): Descriptive text guiding the image generation process.
- image (optional): URI for an input image for image-to-image or inpainting mode.
- mask (optional): URI for an image mask to be used in inpainting mode.
- width (optional): Specifies the width of the generated image.
- height (optional): Specifies the height of the generated image.
- goFast (optional): Enable fast predictions using an optimized model.
- seed (optional): Random seed for reproducibility.
- aspectRatio (optional): Sets the image aspect ratio.
- modelType (optional): Selects the model for image generation (e.g., "dev" or "schnell").
- numOutputs (optional): Number of images to generate (1 to 4).
- imageFormat (optional): Specifies the output image format (e.g., webp, jpg, png).
- guidanceScale (optional): Sets the guidance scale for image diffusion.
- outputQuality (optional): Defines the saved image quality.
- numInferenceSteps (optional): Specifies the number of denoising steps.
Example Input:
{
"seed": 12345,
"image": "https://replicate.delivery/pbxt/MjnbvjRshXnLVI8qjObCDlDGoe9ftmht3KMIVrC73wPD2Wo5/Girl%20in%20a%20bar.jpg",
"width": 1024,
"goFast": false,
"height": 1024,
"prompt": "Une reproduction parfaite du girl in a bar, style Edward Hopper, peinture réaliste, avec [un iPhone] dans les mains. Composition identique, mêmes couleurs, même ambiance, même technique picturale. Ultra détaillé, éclairage précis, texture de peinture visible.",
"loraScale": 0.8,
"modelType": "dev",
"numOutputs": 1,
"aspectRatio": "1:1",
"imageFormat": "webp",
"guidanceScale": 7.05,
"outputQuality": 90,
"extraLoraScale": 1,
"promptStrength": 0.8,
"imageMegapixels": "1",
"numInferenceSteps": 30
}
Output
The action returns a URL link to the generated image in the specified format.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/7f763128-5471-45ec-aae5-c6e370f7de95/58129192-2bb9-4ab3-b59d-393a52cb1b11.webp"
]
Conceptual Usage Example (Python)
Here’s a conceptual Python snippet showing how a developer might call this action using a hypothetical Cognitive Actions execution endpoint:
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 = "be2fef3f-17e0-4ef9-a527-edb25de87b6b" # Action ID for Generate Detailed Images with Edward Hopper Style
# Construct the input payload based on the action's requirements
payload = {
"seed": 12345,
"image": "https://replicate.delivery/pbxt/MjnbvjRshXnLVI8qjObCDlDGoe9ftmht3KMIVrC73wPD2Wo5/Girl%20in%20a%20bar.jpg",
"width": 1024,
"goFast": False,
"height": 1024,
"prompt": "Une reproduction parfaite du girl in a bar, style Edward Hopper, peinture réaliste, avec [un iPhone] dans les mains. Composition identique, mêmes couleurs, même ambiance, même technique picturale. Ultra détaillé, éclairage précis, texture de peinture visible.",
"loraScale": 0.8,
"modelType": "dev",
"numOutputs": 1,
"aspectRatio": "1:1",
"imageFormat": "webp",
"guidanceScale": 7.05,
"outputQuality": 90,
"extraLoraScale": 1,
"promptStrength": 0.8,
"imageMegapixels": "1",
"numInferenceSteps": 30
}
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}
)
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 code, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload is structured according to the required input schema, ensuring that all necessary fields are included.
Conclusion
By leveraging the llpfromparis/ewardhopper Cognitive Actions, developers can effortlessly create visually stunning images that channel the essence of Edward Hopper's artistic style. Whether you're looking to enhance an application with unique imagery or explore creative projects, these actions provide the tools you need for impactful visual storytelling. Start integrating these actions today and elevate your application’s artistic appeal!