Image input output evaluation assesses how well an instruction and input image pair generates an appropriate output image. This evaluation type is particularly useful for validating image generation models and ensuring that generated images match both the given instructions and input image context.

Required Keys

ParameterDescriptionRequired
inputThe instruction to be evaluatedYes
input_image_urlThe URL of the input reference imageYes
output_image_urlThe URL of the generated output imageYes

Required Configuration

ParameterDescriptionRequired
criteriaThe evaluation criteriaYes

Example

from fi.evals import ImageInputOutput, EvalClient
from fi.testcases import MLLMTestCase, MLLMImage

# Initialize the evaluation client
evaluator = EvalClient(
    fi_api_key="your_api_key",
    fi_secret_key="your_secret_key"         
)

# Create a test case using MLLMImage objects
test_case_with_objects = MLLMTestCase(
    input="Generate a similar image but change the background to a beach setting",
    input_image_url=MLLMImage(url="https://example.com/input-image.jpg"),
    output_image_url=MLLMImage(url="https://example.com/generated-image.jpg")
)

# Or create a test case using URL strings
test_case = MLLMTestCase(
    input="Generate a similar image but change the background to a beach setting",
    input_image_url="https://example.com/input-image.jpg",
    output_image_url="https://example.com/generated-image.jpg"
)

# Initialize the image input-output evaluator
image_eval = ImageInputOutput(
    config = {
        "criteria": """Evaluate the output image based on: 
        - Adherence to input instruction
        - Preservation of key elements from input image
        - Quality of background modification
        - Overall composition
        - Image quality and coherence"""
    }
)

# Run the evaluation
result = evaluator.evaluate(image_eval, test_case)
print(result) # Will return a score between 0 and 1