Enhance Your Image Quality Assessment with Tres Iqa

26 Apr 2025
Enhance Your Image Quality Assessment with Tres Iqa

In today's digital landscape, image quality plays a crucial role in user experience, whether it's for web design, e-commerce, or social media. Tres Iqa offers powerful Cognitive Actions to evaluate and improve image quality effectively. One of its standout features is the ability to predict image quality based on various distortions such as noise, blurring, and compression artifacts. By leveraging advanced techniques like No-Reference Image Quality Assessment via Transformers, Tres Iqa simplifies the process of ensuring high-quality images, ultimately saving time and enhancing the visual appeal of your projects.

Common use cases for this action include assessing images before uploading to websites, optimizing images for better load times without compromising quality, and analyzing images in photography applications to help users select the best shots. With Tres Iqa, developers can automate these processes, allowing for faster and more efficient workflows.

Prerequisites

To get started with Tres Iqa, you'll need an API key for the Cognitive Actions service and a basic understanding of making API calls.

Predict Image Quality

The "Predict Image Quality" action evaluates the quality of an image by predicting a score that reflects potential distortions. A lower score indicates a higher quality image, enabling developers to make informed decisions about which images to use or how to enhance them. This action falls under the category of image analysis and is essential for ensuring that users are presented with the best visual content.

Input Requirements

The action requires a single input: the URI of the image to be analyzed. The input must be accessible via a valid URL, ensuring that the image can be fetched and evaluated effectively.

Example Input:

{
  "inputImage": "https://replicate.delivery/pbxt/IC61s3dEF28OhrwRXokmtENnM75qwzUCvFAqqnn6R4Qse3sY/alberta-2297204_960_720.jpg"
}

Expected Output

The output will be a numerical score that quantifies the quality of the image. For instance, an output score of approximately 17.29 indicates the level of quality, with lower scores representing better image quality.

Use Cases for this specific action:

  • Web Development: Automatically assess images before they are uploaded to ensure only high-quality visuals are displayed on a website.
  • E-commerce Platforms: Optimize product images by evaluating and enhancing quality, leading to better customer engagement and sales.
  • Photography Applications: Provide tools for photographers to analyze their shots and select the best images based on quality scores.
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 = "928f3d48-6e87-47b5-8a1f-1ce51297aad2" # Action ID for: Predict Image Quality

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "inputImage": "https://replicate.delivery/pbxt/IC61s3dEF28OhrwRXokmtENnM75qwzUCvFAqqnn6R4Qse3sY/alberta-2297204_960_720.jpg"
}

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

Tres Iqa's image quality prediction action streamlines the process of assessing and improving image quality, making it invaluable for developers working in various industries. By automating this task, you can enhance user experiences, optimize visual content, and ultimately drive better engagement. As you integrate Tres Iqa into your applications, consider exploring additional Cognitive Actions to further enrich your projects and meet the demands of today's digital audience.