Transform Text into Stunning Images with URPM V1.3

25 Apr 2025
Transform Text into Stunning Images with URPM V1.3

In the ever-evolving world of artificial intelligence, visual content generation has emerged as a powerful tool for developers. The URPM V1.3 offers cutting-edge Cognitive Actions that allow you to create images from text prompts, enhance existing images, and modify them through inpainting. This service simplifies the process of image generation, making it accessible and efficient for developers looking to integrate these capabilities into their applications. Whether you are designing marketing materials, creating digital art, or generating visual content for social media, URPM V1.3 can streamline your workflow and enhance creativity.

Prerequisites

To get started with URPM V1.3, you will need a Cognitive Actions API key and a basic understanding of making API calls to utilize the image generation features effectively.

Execute URPM V1.3 Model for Image Generation

The Execute URPM V1.3 Model for Image Generation serves as the core functionality of this service. It allows users to transform textual descriptions into vivid images, perform modifications on existing images, and inpaint areas of images seamlessly. By leveraging customizable parameters such as strength, guidance scale, and various scheduling options, developers can influence the creative output to meet specific needs.

Input Requirements

To use this action, your input must be structured as follows:

  • prompt: A detailed text description guiding the image generation.
  • image: A URI reference to the input image for img2img and inpainting modes.
  • mask: A URI to the mask image specifically for inpainting.
  • width: The desired width of the output image (default: 512 pixels).
  • height: The desired height of the output image (default: 728 pixels).
  • strength: A value between 0 and 1 indicating the degree of transformation.
  • guidanceScale: A scaling factor influencing the text prompt's impact (default: 7.5).
  • scheduler: The method of scheduling for the generation process (default: K_EULER_ANCESTRAL).
  • negativePrompt: A description of features to avoid in the image.
  • numInferenceSteps: The number of steps during generation (default: 20).
  • useKarrasSigmas: A boolean for using Karras sigmas in the process.

Expected Output

The output will be a URI to the generated image, allowing easy access and integration into your projects.

Use Cases for this specific action

  • Marketing: Generate captivating visuals for advertisements or social media posts based on specific themes or products.
  • Content Creation: Create unique images to accompany blog posts or articles, enhancing reader engagement.
  • Game Development: Develop concept art or assets for characters and environments from descriptive text.
  • Art and Design: Assist artists in visualizing their ideas by generating images based on detailed prompts.
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 = "a40a7e5a-bbec-47fa-90c8-ee7a22645e67" # Action ID for: Execute URPM V1.3 Model for Image Generation

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "width": 512,
  "height": 728,
  "prompt": "actual 8K portrait photo of gareth person, portrait, happy colors, bright eyes, clear eyes, warm smile, smooth soft skin, big dreamy eyes, beautiful intricate colored hair, symmetrical, anime wide eyes, soft lighting, detailed face, by makoto shinkai, stanley artgerm lau, wlop, rossdraws, concept art, digital painting, looking into camera",
  "strength": 1,
  "scheduler": "K_EULER_ANCESTRAL",
  "guidanceScale": 7.5,
  "negativePrompt": "disfigured, animated, cartoon, duplicate, kitsch, ugly, oversaturated, greain, low-res, deformed, blurry, bad anatomy, poorly drawn face, mutation, mutated, extra limb, poorly drawn hands, missing limb, floating limbs, disconnected limbs, malformed hands, blur, out of focus, long neck, long body, disgusting, poorly drawn, childish, mutilated, mangled, old, surreal, calligraphy, sign, writing, watermark, text, body out of frame, extra legs, extra arms, extra feet, out of frame, poorly drawn feet, cross-eye",
  "useKarrasSigmas": false,
  "numInferenceSteps": 20
}

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 URPM V1.3 model revolutionizes the way developers can generate and manipulate images, offering a wide array of applications across various industries. By integrating this Cognitive Action into your projects, you can save time, enhance creativity, and produce high-quality visual content tailored to your specific needs. Start exploring the possibilities today and elevate your development projects with the power of AI-driven image generation!