Create Stunning Images with Gsat's Inpainting and Img2Img Actions

26 Apr 2025
Create Stunning Images with Gsat's Inpainting and Img2Img Actions

In the world of digital content creation, having the ability to generate high-quality images quickly can be a game changer. Gsat offers powerful Cognitive Actions that enable developers to create stunning visuals through inpainting or image-to-image transformations. These actions allow users to generate new images based on prompts, while offering flexibility in terms of image dimensions, quality, and style. Whether you're working on a game, an application, or a marketing campaign, Gsat's capabilities can help streamline your workflow and enhance your creative projects.

Imagine needing a unique image for your app or wanting to refine an existing one. Gsat's image generation actions can assist in creating visuals that meet specific requirements, making them invaluable for designers, marketers, and developers alike. The ability to customize output and choose between different models for quality or speed further empowers users to meet their project goals efficiently.

Prerequisites

To utilize Gsat's Cognitive Actions, you'll need an API key and a basic understanding of how to make API calls. This will allow you to seamlessly integrate image generation capabilities into your applications.

Generate Image Using Inpainting or Img2Img

This action allows you to create new images from prompts using either an image-to-image mode or inpainting. You can choose between two models: 'dev' for detailed, high-quality images or 'schnell' for faster generation. The action supports various parameters to customize the image dimensions, quality, and style.

Input Requirements

To invoke this action, you must provide a prompt that describes the image you want to generate. Additionally, you can include an input image or mask to guide the generation process. Other optional parameters allow you to specify the model, dimensions, aspect ratio, and more.

Example Input:

{
  "mask": "https://example.com/mask.png",
  "image": "https://example.com/input.png",
  "model": "dev",
  "prompt": "A futuristic satellite image",
  "aspectRatio": "1:1",
  "guidanceScale": 3,
  "outputQuality": 80,
  "enableFastMode": false,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "imageOutputFormat": "webp",
  "loraStrengthScale": 1,
  "approximateMegapixels": "1",
  "extraLoraStrengthScale": 1,
  "numberOfInferenceSteps": 28
}

Expected Output

The output will be a generated image that reflects the provided prompt and parameters. The image will be returned in the specified format, such as webp, jpg, or png.

Example Output:

[
  "https://assets.cognitiveactions.com/generated_image.webp"
]

Use Cases for This Action

  • Creative Projects: Artists and designers can utilize this action to generate unique visuals for their portfolios or projects.
  • Marketing Materials: Marketers can quickly create compelling images for advertisements or social media posts, ensuring they stand out.
  • Game Development: Developers can generate game assets, such as characters or environments, tailored to specific themes or styles.
  • Content Generation: Bloggers and content creators can produce relevant images that enhance their articles or presentations.

```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 = "c3fe3133-b041-4f1b-9e58-3e03a8ad9b29" # Action ID for: Generate Image Using Inpainting or Img2Img

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "mask": "https://replicate.delivery/pbxt/Maf6HKHcBDFcTB4X1GqTXOa7irUkvZz9U9U4g5D0rri02xTs/Screenshot%202025-03-02%20at%2017.07.03.png",
  "image": "https://replicate.delivery/pbxt/Maf6GtNh2X333pSsHrSbfCr6EIOzSTYCVsSb621fjc5FuCpC/Screenshot%202025-03-02%20at%2017.07.03.png",
  "model": "dev",
  "prompt": "GSAT  satellite image same of the originale",
  "aspectRatio": "1:1",
  "guidanceScale": 3,
  "outputQuality": 80,
  "enableFastMode": false,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "imageOutputFormat": "webp",
  "loraStrengthScale": 1,
  "approximateMegapixels": "1",
  "extraLoraStrengthScale": 1,
  "numberOfInferenceSteps": 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
Gsat's image generation capabilities offer a powerful tool for developers looking to streamline their creative processes. With the ability to generate high-quality images from prompts and customize various parameters, you can enhance your projects, whether they are for marketing, design, or gaming. As you explore these actions, consider how they can fit into your workflow and inspire your next creative endeavor. Start integrating Gsat into your projects today for a more efficient and imaginative approach to image creation!