Skip to main content

SAMScore Similarity Metric

Project description

SAMScore: A Semantic Structural Similarity Metric for Image Translation Evaluation

Yunxiang Li, Meixu Chen, Wenxuan Yang, Kai Wang, Jun Ma, Alan C. Bovik, You Zhang.

Arxiv
Open In Colab

Quick start

Run pip install samscore.

pip install samscore
pip install git+https://github.com/facebookresearch/segment-anything.git

The following Python code is all you need.

import requests
import os
import samscore

def download_image(url, save_path):
    response = requests.get(url)
    response.raise_for_status()  # Raise an exception if the request was unsuccessful

    with open(save_path, 'wb') as file:
        file.write(response.content)
os.makedirs('imgs', exist_ok=True)
# Example usage
image_url = 'https://i.ibb.co/yFFg5pn/n02381460-20-real.png'
save_location = 'imgs/real.png'
download_image(image_url, save_location)

image_url = 'https://i.ibb.co/GCQ2jQy/n02381460-20-fake.png'
save_location = 'imgs/fake.png'
download_image(image_url, save_location)

## Initializing the model
SAMScore_Evaluation = samscore.SAMScore(model_type = "vit_b" )
samscore_result = SAMScore_Evaluation.evaluation_from_path(source_image_path='imgs/real.png',  generated_image_path='imgs/fake.png')

print('SAMScore: %.4f'%samscore_result)

Citation

If you find this repository useful for your research, please use the following.

@inproceedings{li2023samscore,
  title={SAMScore: A Semantic Structural Similarity Metric for Image Translation Evaluation},
  author={Yunxiang Li, Meixu Chen, Wenxuan Yang, Kai Wang, Jun Ma, Alan C. Bovik, You Zhang},
  booktitle={arxiv},
  year={2023}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

samscore-1.34.tar.gz (10.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page