Create Stunning Images with Segev Test Cognitive Actions

25 Apr 2025
Create Stunning Images with Segev Test Cognitive Actions

The Segev Test service offers powerful Cognitive Actions designed to enhance your image generation capabilities. With its advanced model, you can create high-quality images based on specific prompts, making it an invaluable tool for developers looking to integrate image generation into their applications. The ability to customize settings such as resolution, aspect ratio, and style allows for a high degree of flexibility, while the support for image inpainting provides additional creative possibilities.

Common use cases for the Segev Test include generating unique visuals for marketing campaigns, creating custom artwork for applications, and enhancing existing images by modifying specific areas. By leveraging this service, developers can streamline their workflows and deliver more engaging content to users.

Before diving into the details, ensure you have a Cognitive Actions API key and a basic understanding of making API calls.

Generate Image with Inpainting

The "Generate Image with Inpainting" action is designed to create images based on user-defined prompts and optional image masks. This action caters to a variety of needs, whether you're looking for high-quality outputs or faster generation times. It solves the problem of generating customized images that align closely with user specifications, offering a unique solution for content creators and developers.

Input Requirements

To utilize this action, you'll need to provide a prompt and can optionally include parameters such as an image mask, seed for reproducibility, dimensions, and model type. The input schema is structured to accept various properties, ensuring that you can tailor the generated image to your needs.

Example Input:

{
  "prompt": "With a close-up, well-lit front-facing photo, \nHe is standing in a bright, outdoor setting with soft natural light, wearing a casual yet stylish button-up shirt.",
  "modelType": "dev",
  "inferenceSteps": 50,
  "numberOfOutputs": 1,
  "promptIntensity": 0.8,
  "imageAspectRatio": "2:3",
  "mainLoraStrength": 1,
  "imageOutputFormat": "png",
  "imageGuidanceScale": 1.5,
  "imageOutputQuality": 100,
  "additionalLoraStrength": 1
}

Expected Output

The action will return a URL to the generated image, allowing for easy integration into your projects. The output will be in the specified format, ensuring that it meets your quality and style requirements.

Example Output:

"https://assets.cognitiveactions.com/invocations/ea63ac13-e06a-4a0e-a90b-98ac5379cb25/3ebffc94-3e1f-47da-a6da-ca8d063690fb.png"

Use Cases for this Action

  • Marketing and Advertising: Generate unique images for ads based on specific themes or products.
  • Content Creation: Create custom artwork or illustrations for blogs, websites, or social media.
  • Image Modification: Use inpainting to modify existing images by replacing or altering specific areas, enhancing the overall visual impact.
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 = "e630a95b-eb39-4777-95c8-e98e454f58ed" # Action ID for: Generate Image with Inpainting

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "prompt": "With a close-up, well-lit front-facing photo, \nHe is standing in a bright, outdoor setting with soft natural light, wearing a casual yet stylish button-up shirt. The background features a blurred park scene with trees, creating a relaxed, friendly atmosphere. s3g3v posture is confident\nhis body type is fit",
  "modelType": "dev",
  "inferenceSteps": 50,
  "numberOfOutputs": 1,
  "promptIntensity": 0.8,
  "imageAspectRatio": "2:3",
  "mainLoraStrength": 1,
  "imageOutputFormat": "png",
  "imageGuidanceScale": 1.5,
  "imageOutputQuality": 100,
  "additionalLoraStrength": 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

The Segev Test's "Generate Image with Inpainting" action provides a robust solution for developers seeking to create customized images efficiently. Its flexibility and range of options enable you to meet diverse creative needs, ensuring that you can deliver high-quality visuals tailored to your audience.

To get started, explore the various input parameters and experiment with different prompts to see the full potential of this action. Integrate it into your projects and elevate your content creation process today!