Semantic Similarity

The Semantic Similarity Test in RagaAI assesses the likeness between high-resolution (HR) and low-resolution (LR) images.

Execute Test:

The provided code snippet is intended to set up and execute a Semantic Similarity Test in RagaAI to assess the likeness between HR and LR images.

Step 1: Define the Semantic Similarity Rules

Start by setting the rules that will assess the semantic similarity between the image pairs.

rules = LQRules()
rules.add(metric="similarity_score", metric_threshold=0.2)

semantic_similarity_test = semantic_similarity(test_session=test_session,
                                      dataset_name = "dataset_name",
                                      test_name = "semantic_similarity_test",
                                      type = "semantic_similarity",
                                      output_type="super_resolution",
                                      embed_col_name="lr_embedding",
                                      generated_embed_col_name="hr_embedding",
                                      rules=rules)
                                      
test_session.add(semantic_similarity_test)

test_session.run()
  • LQRules(): Initialises the rules for the semantic similarity test.

  • rules.add(): Adds a rule to evaluate the similarity:

    • metric: The performance metric to use, "similarity_score" in this instance.

    • metric_threshold: The threshold value for the similarity score, indicating the level of likeness required.

  • semantic_similarity(): Prepares the semantic similarity test with the following parameters:

    • test_session: The session object tied to your RagaAI project.

    • dataset_name: The name of the dataset you're working with.

    • test_name: A descriptive name for this test, e.g., "semantic_similarity_test".

    • type: The type of test, which is "semantic_similarity" in this context.

    • output_type: The type of output, "super_resolution" here, indicating the nature of the images being compared.

    • embed_col_name: The column name containing embeddings of the LR images.

    • generated_embed_col_name: The column name containing embeddings of the HR images.

    • rules: The ruleset you've defined for measuring semantic similarity.

test_session.add(): Registers the semantic similarity test with the session.

test_session.run(): Initiates the execution of all tests within the session, including the semantic similarity test.

By following these instructions, you have initiated a Semantic Similarity Test in RagaAI. This process will help you quantify the semantic likeness between your dataset's LR and HR images.

Analysing Test Results

Understanding Similarity Scores

  • Score Calculation: The test computes a similarity score for each HR-LR image pair.

Analysing Results

  • Embedding View: Use this interactive feature to observe the distribution of similarity scores.

  • Datagrid View: Visualise the HR and LR images along with their scores.

Detailed Image Analysis

  • Image View: Clicking on an image in the Datagrid View opens a detailed view, where you can see the HR image alongside its corresponding LR image and their calculated similarity score.

This test is instrumental in ensuring the super-resolution process maintains fidelity across image resolutions.

After the test concludes, examine the results to see how well your HR images are matching up to the LR ones.

Last updated