Create Stunning Photorealistic Images Effortlessly with Metarb

26 Apr 2025
Create Stunning Photorealistic Images Effortlessly with Metarb

Metarb offers a powerful API that enables developers to generate photorealistic images based on detailed text prompts. By leveraging advanced machine learning algorithms, Metarb simplifies the image creation process, providing users with the tools to produce high-quality visuals quickly and efficiently. This is particularly beneficial for developers working in fields such as marketing, e-commerce, and content creation, where compelling imagery is essential.

Imagine being able to create unique product images or stunning landscapes with just a few lines of descriptive text. Metarb's capabilities include image-to-image conversion and inpainting, allowing for customization in aspects such as resolution, aspect ratio, and more. This flexibility not only saves time but also enhances creativity, enabling developers to bring their visions to life in a way that was previously unattainable.

Prerequisites

To get started with Metarb, you will need a valid API key for the Cognitive Actions service and a basic understanding of how to make API calls.

Generate Photorealistic Image

The "Generate Photorealistic Image" action creates stunningly realistic images based on user-defined text prompts. This action addresses the challenge of generating high-quality visuals tailored to specific needs, whether for product displays, creative projects, or artistic explorations.

Input Requirements

The input for this action is a JSON object that must include the following:

  • prompt: A detailed description of the image you want to generate.
  • Additional optional parameters such as image, mask, width, height, imageFormat, and more can be included to customize the output.

Example input structure:

{
  "prompt": "A detailed description of the desired image.",
  "imageFormat": "webp",
  "outputCount": 1,
  "imageQuality": 90,
  "guidanceScale": 3.5,
  "loraIntensity": 1,
  "inferenceModel": "dev",
  "inferenceSteps": 28,
  "promptIntensity": 0.8,
  "imageAspectRatio": "3:4",
  "additionalLoraIntensity": 1
}

Expected Output

The expected output is a URL link to the generated image, which will be a photorealistic representation based on the provided prompt. The image will be generated in the specified format (e.g., webp, jpg, png) and can vary in quality based on the input parameters.

Example output:

[
  "https://assets.cognitiveactions.com/invocations/7fdf7697-5d35-4f97-a0a1-746e9d0a8953/4056caee-2d5b-463e-ac2c-f4c308641e02.webp"
]

Use Cases for this Specific Action

  • E-commerce Product Images: Quickly generate unique product visuals that stand out in online listings.
  • Marketing Campaigns: Create compelling imagery for advertisements and social media posts without the need for a graphic designer.
  • Content Creation: Enable content creators and bloggers to produce stunning visuals that complement their written content, enhancing audience engagement.
  • Artistic Projects: Artists can explore new concepts and ideas by generating images based on descriptive prompts, allowing for experimentation and inspiration.
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 = "7ae63cb6-6e34-4942-8b19-0040f1cc0d70" # Action ID for: Generate Photorealistic Image

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "prompt": "MetaRB reate a photorealistic image of MetaRB glasses resting on a smooth rock at the top of Corcovado Mountain in Rio de Janeiro, with the Christ the Redeemer statue visible in the background. The sunglasses, with sleek black frames and reflective lenses, are positioned at an angle that captures the panoramic view of the cityscape and the distant coastline reflected on the lenses. The sunlight glints off the frames, highlighting their elegant design, while the lush greenery surrounding the rock adds a touch of natural beauty.\n\nThe image is taken using a Canon EOS R6 with a 35mm f/1.4 lens, set to f/4.0 for a balanced depth of field, ISO 100, and a shutter speed of 1/1000 sec. The focus is sharp on the sunglasses, with the iconic statue and sweeping view of Rio slightly blurred in the background, emphasizing the product while still showcasing the stunning location.",
  "imageFormat": "webp",
  "outputCount": 1,
  "imageQuality": 90,
  "guidanceScale": 3.5,
  "loraIntensity": 1,
  "inferenceModel": "dev",
  "inferenceSteps": 28,
  "promptIntensity": 0.8,
  "imageAspectRatio": "3:4",
  "additionalLoraIntensity": 1
}

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

Metarb's "Generate Photorealistic Image" action provides developers with a powerful tool to create high-quality, customized visuals effortlessly. By automating the image generation process, users can save time, enhance creativity, and produce stunning graphics for various applications. Whether you're in e-commerce, marketing, or content creation, harnessing the capabilities of Metarb can significantly elevate your projects.

As a next step, consider integrating Metarb into your workflow to unlock the full potential of your visual content creation.