https://github.com/Kent0n-Li/SAMScore
https://github.com/Kent0n-Li/SAMScore
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/Kent0n-Li/SAMScore
- Owner: Kent0n-Li
- License: bsd-2-clause
- Created: 2023-05-23T17:38:07.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-23T20:31:50.000Z (almost 2 years ago)
- Last Synced: 2024-04-25T13:21:37.022Z (over 1 year ago)
- Language: Jupyter Notebook
- Size: 2.96 MB
- Stars: 14
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- Awesome-Segment-Anything - [code
README
## [SAMScore: A Content Structural Similarity Metric for Image Translation Evaluation (IEEE TAI)](https://ieeexplore.ieee.org/abstract/document/10857645)
[Yunxiang Li](https://www.yunxiangli.top/), Meixu Chen, Kai Wang, [Jun Ma](https://scholar.google.com/citations?hl=zh-CN&user=bW1UV4IAAAAJ), [Alan C. Bovik](https://www.ece.utexas.edu/people/faculty/alan-bovik), [You Zhang](https://profiles.utsouthwestern.edu/profile/161901/you-zhang.html).

### Quick start
Run `pip install samscore`.
```python
pip install git+https://github.com/ChaoningZhang/MobileSAM.git
pip install timm
pip install samscore
pip install git+https://github.com/facebookresearch/segment-anything.git
```
The following Python code is all you need.
```python
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
# You can choose "vit_t", "vit_l", "vit_b", "vit_h"
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.
```
@article{li2025samscore,
title={SAMScore: A Content Structural Similarity Metric for Image Translation Evaluation},
author={Li, Yunxiang and Chen, Meixu and Wang, Kai and Ma, Jun and Bovik, Alan C and Zhang, You},
journal={IEEE Transactions on Artificial Intelligence},
year={2025},
publisher={IEEE}
}
```

