이미지 품질 평가를위한 Pytorch 도구 상자순수한 파이썬과 파이터가있는 IQA 도구 상자. IQA 방법에 대한 포괄적 인 설문 조사 및 IQA 데이터 세트에 대한 다운로드 링크는 멋진 이미지 품질 평가를 참조하십시오.
이것은 순수한 Python 및 Pytorch 로 구축 된 포괄적 인 이미지 품질 평가 (IQA) 도구 상자입니다. 우리는 많은 주류 전체 참조 (FR)를 상환하고 참조 (NR) 메트릭을 제공합니다 (결과는 공식 MATLAB 스크립트로 교정됩니다). GPU 가속을 사용하면 대부분의 구현이 MATLAB보다 훨씬 빠릅니다. 자세한 내용은 다음 문서를 참조하십시오.
? 모델 카드 | ? ️ 데이터 세트 카드 | ? 데이터 세트 다운로드 | 문서 | ?기준
fid 추가하고 fid_metric(..., distance_type='mmd', kernel_type='rbf') 와 함께 사용하십시오. 자세한 내용은 CMMD를 참조하십시오. 기부금에 대한 Ina에게 감사드립니다.fid_dinov2 추가하고 DGM-Eval을 참조하십시오.pyiqa.load_dataset 추가하십시오.compare2score 및 deepdc 추가하십시오. Hanwei에게 그들의 위대한 일에 감사 드리며 공식 논문을 참조하십시오.topiq_nr-face 업데이트하십시오. 그들의 일 덕분에! ?msswd 추가하십시오. 그들의 일 덕분에! ?qalign 및 qalign_8bit 를 제외한 대부분은 6GB 미만의 GPU 메모리가 필요합니다.qalign_4bit 및 qalign_8bit 추가하십시오.piqe 메트릭 및 niqe_matlab, brisque_matlab 추가하십시오 (결과는 MATLAB R2021B로 보정되었습니다).lpips+ 및 lpips-vgg+ 추가하십시오.arniqa 와 다른 데이터 세트에 대해 훈련 된 차이를 추가하고 여기에서 공식 리포를 참조하십시오. Lorenzo Agnolucci의 기여에 감사드립니다.pyiqa 명령으로 inception_score 및 콘솔 입력 점을 추가하십시오.unique 추가, 여기에서 공식 리포를 참조하십시오. Weixia Zhang의 기여에 감사드립니다. # Install with pip
pip install pyiqa
# Install latest github version
pip uninstall pyiqa # if have older version installed already
pip install git+https://github.com/chaofengc/IQA-PyTorch.git
# Install with git clone
git clone https://github.com/chaofengc/IQA-PyTorch.git
cd IQA-PyTorch
pip install -r requirements.txt
python setup.py developCommandLine 인터페이스와 함께 패키지를 사용할 수 있습니다.
# list all available metrics
pyiqa -ls
# test with default settings
pyiqa [metric_name(s)] -t [image_path or dir] -r [image_path or dir] --device [cuda or cpu] --verbose import pyiqa
import torch
# list all available metrics
print ( pyiqa . list_models ())
device = torch . device ( "cuda" ) if torch . cuda . is_available () else torch . device ( "cpu" )
# create metric with default setting
iqa_metric = pyiqa . create_metric ( 'lpips' , device = device )
# check if lower better or higher better
print ( iqa_metric . lower_better )
# example for iqa score inference
# Tensor inputs, img_tensor_x/y: (N, 3, H, W), RGB, 0 ~ 1
score_fr = iqa_metric ( img_tensor_x , img_tensor_y )
# img path as inputs.
score_fr = iqa_metric ( './ResultsCalibra/dist_dir/I03.bmp' , './ResultsCalibra/ref_dir/I03.bmp' )
# For FID metric, use directory or precomputed statistics as inputs
# refer to clean-fid for more details: https://github.com/GaParmar/clean-fid
fid_metric = pyiqa . create_metric ( 'fid' )
score = fid_metric ( './ResultsCalibra/dist_dir/' , './ResultsCalibra/ref_dir' )
score = fid_metric ( './ResultsCalibra/dist_dir/' , dataset_name = "FFHQ" , dataset_res = 1024 , dataset_split = "trainval70k" ) 그라디언트 전파는 기본적으로 비활성화됩니다. as_loss=True 를 손실 함수로 활성화하십시오. 모든 측정 항목이 역전술을 지원하는 것은 아닙니다. 모델 카드를 참조하고 lower_better 방식으로 사용하고 있는지 확인하십시오.
lpips_loss = pyiqa . create_metric ( 'lpips' , device = device , as_loss = True )
ssim_loss = pyiqa . create_metric ( 'ssimc' , device = device , as_loss = True )
loss = 1 - ssim_loss ( img_tensor_x , img_tensor_y ) # ssim is not lower better 또한 모델을 재교육하거나 미세 조정하려는 경우 사용자 정의 설정 및 가중치를 사용하는 유연한 방법을 제공합니다.
iqa_metric = pyiqa . create_metric ( 'topiq_nr' , device = device , ** custom_opts )
# Note that if you train the model with this package, the weights will be saved in weight_dict['params']. Otherwise, please set weight_keys=None.
iqa_metric . load_weights ( 'path/to/weights.pth' , weight_keys = 'params' )입력 디렉토리/이미지 및 참조 디렉토리/이미지가있는 테스트 스크립트 예제.
# example for FR metric with dirs
python inference_iqa.py -m LPIPS[or lpips] -i ./ResultsCalibra/dist_dir[dist_img] -r ./ResultsCalibra/ref_dir[ref_img]
# example for NR metric with single image
python inference_iqa.py -m brisque -i ./ResultsCalibra/dist_dir/I03.bmp 구성 파일 pyiqa/default_dataset_configs.yml 통해 인기있는 IQA 데이터 세트를 쉽게로드 할 수있는 쉬운 방법을 제공합니다. 지정된 데이터 세트는 Huggingface IQA-Pytorch-Dataset에서 자동으로 다운로드됩니다. 아래의 예제 코드를 참조하십시오.
from pyiqa import get_dataset_info , load_dataset
# list all available datasets
print ( get_dataset_info (). keys ())
# load dataset with default options and official split
dataset = load_dataset ( 'koniq10k' , data_root = './datasets' , force_download = False , split_index = 'official_split' , phase = 'test' )
print ( f'Loaded dataset, len= { len ( dataset ) } , { dataset [ 0 ]. keys () } ' )
print ( dataset [ 0 ][ 'img' ]. shape )
# split_ratio: train/test/val
dataset = load_dataset ( 'csiq' , data_root = './datasets' , force_download = False , split_index = 1 , split_ratio = '622' , phase = 'test' )
print ( f'Loaded dataset, len= { len ( dataset ) } , { dataset [ 0 ]. keys () } ' )
print ( dataset [ 0 ][ 'img' ]. shape )
# or use dataset options
dataset_opts = {
'split_index' : 1 ,
'split_ratio' : '622' ,
'phase' : 'test' ,
'augment' : {
'resize' : 256 ,
'center_crop' : 224 ,
}
}
dataset = load_dataset ( 'csiq' , data_root = './datasets' , force_download = False , dataset_opts = dataset_opts )
print ( f'Loaded dataset, len= { len ( dataset ) } , { dataset [ 0 ]. keys () } ' )
print ( dataset [ 0 ][ 'img' ]. shape ) dataset_opts 에 대한 자세한 내용은 데이터 세트 카드를 참조하십시오.
Matlab 또는 Python의 공식 스크립트와 비교하여 Python 구현의 정확성을 확인하려면 결과 교정을 참조하십시오.
편의를 위해, 우리는 모든 관련 데이터 세트를 IQA-Toolbox-Dataset를 포옹하고 IQA-Toolbox-Dataset-Metainfo에 대한 해당 메타 정보 파일에 업로드합니다. 다음은 Huggingface에서 다운로드 할 수있는 예제 코드입니다.
주의
우리는 학업, 연구 및 교육 목적을위한 데이터 세트 만 수집합니다. 사용자가 사용 지침, 라이센스 용어 및 각 데이터 세트의 원래 제작자 또는 소유자가 제시 한 조건을 준수하는 것이 중요합니다.
import os
from huggingface_hub import snapshot_download
save_dir = './datasets'
os . makedirs ( save_dir , exist_ok = True )
filename = "koniq10k.tgz"
snapshot_download ( "chaofengc/IQA-Toolbox-Datasets" , repo_type = "dataset" , local_dir = save_dir , allow_patterns = filename , local_dir_use_symlinks = False )
os . system ( f"tar -xzvf { save_dir } / { filename } -C { save_dir } " ) git clone 사용하여 Huggingface에서 메타 정보를 다운로드하거나 git pull 으로 업데이트하십시오.
cd ./datasets
git clone https://huggingface.co/datasets/chaofengc/IQA-Toolbox-Datasets-metainfo meta_info
cd ./datasets/meta_info
git pull
특정 데이터 세트 옵션에 대한 예는 ./pyiqa/default_dataset_configs.yml 에서 찾을 수 있습니다. 데이터 로더 인터페이스 및 메타 정보 파일의 세부 사항은 데이터 세트 준비에서 찾을 수 있습니다.
우리는 가능한 경우 평가를 위해 공식 모델을 사용합니다. 그렇지 않으면 다음 설정을 사용하여 단순성과 일관성을 위해 다른 모델을 교육하고 평가합니다.
| 메트릭 유형 | 기차 | 시험 | 결과 |
|---|---|---|---|
| 정말로 | Kadid-10K | CSIQ, LIVE, TID2008, TID2013 | FR 벤치 마크 |
| NR | Koniq-10K | Livec, Koniq-10K (공식 분할), TID2013, SPAQ | NR 벤치 마크 |
| 미적 IQA | 아바 | AVA (공식 분할) | IAA 벤치 마크 |
| 얼굴 IQA | cgfiqa | CGFIQA (공식 분할) | 직면 IQA 벤치 마크 |
| 능률 | CPU/GPU 시간, GPU 메모리 | 평균적으로 | 효율성 벤치 마크 |
결과는 다음과 같이 계산됩니다.
기본적으로 우리는 교육을 위해 가장 큰 기존 데이터 세트를 사용하고 공정한 비교를 위해 교차 데이터 세트 평가 성능을 사용합니다. 다음 모델은 공식적인 가중치를 제공하지 않으며 스크립트에 의해 재 훈련됩니다.
| 메트릭 유형 | 복제 된 모델 |
|---|---|
| 정말로 | wadiqam_fr |
| NR | cnniqa , dbcnn , hyperiqa , wadiqam_nr |
| 미적 IQA | nima , nima-vgg16-ava |
메모
nima 에는 inception_resnet_v2 사용합니다.다음은 다른 데이터 세트에서 성능 벤치 마크를 얻는 예제 스크립트입니다.
# NOTE: this script will test ALL specified metrics on ALL specified datasets
# Test default metrics on default datasets
python benchmark_results.py -m psnr ssim -d csiq tid2013 tid2008
# Test with your own options
python benchmark_results.py -m psnr --data_opt options/example_benchmark_data_opts.yml
python benchmark_results.py --metric_opt options/example_benchmark_metric_opts.yml tid2013 tid2008
python benchmark_results.py --metric_opt options/example_benchmark_metric_opts.yml --data_opt options/example_benchmark_data_opts.ymlLiveChallenge 데이터 세트에서 DBCNN을 훈련시키는 예
# train for single experiment
python pyiqa/train.py -opt options/train/DBCNN/train_DBCNN.yml
# train N splits for small datasets
python pyiqa/train_nsplits.py -opt options/train/DBCNN/train_DBCNN.yml분산 교육의 예
torchrun --nproc_per_node=2 --master_port=4321 pyiqa/train.py -opt options/train/CLIPIQA/train_CLIPIQA_koniq10k.yml --launcher pytorch이 저장소에 대한 모든 기여는 대단히 감사합니다. 기여 지침에 대한 기여 지침을 따르십시오.
이 작업은 NTU S-LAB 라이센스 및 Creative Commons Attribution-Noncommercial-Sharealike 4.0 국제 라이센스에 따라 라이센스가 부여됩니다.
우리의 코드가 귀하의 연구에 도움이되는 경우 다음 인용을 사용하십시오.
@misc { pyiqa ,
title = { {IQA-PyTorch}: PyTorch Toolbox for Image Quality Assessment } ,
author = { Chaofeng Chen and Jiadi Mo } ,
year = { 2022 } ,
howpublished = " [Online]. Available: url{https://github.com/chaofengc/IQA-PyTorch} "
}또한 유용한 경우 이미지 품질 평가에 대한 작품을 인용하십시오.
@article { chen2024topiq ,
author = { Chen, Chaofeng and Mo, Jiadi and Hou, Jingwen and Wu, Haoning and Liao, Liang and Sun, Wenxiu and Yan, Qiong and Lin, Weisi } ,
title = { TOPIQ: A Top-Down Approach From Semantics to Distortions for Image Quality Assessment } ,
journal = { IEEE Transactions on Image Processing } ,
year = { 2024 } ,
volume = { 33 } ,
pages = { 2404-2418 } ,
doi = { 10.1109/TIP.2024.3378466 }
} @article { wu2024qalign ,
title = { Q-Align: Teaching LMMs for Visual Scoring via Discrete Text-Defined Levels } ,
author = { Wu, Haoning and Zhang, Zicheng and Zhang, Weixia and Chen, Chaofeng and Li, Chunyi and Liao, Liang and Wang, Annan and Zhang, Erli and Sun, Wenxiu and Yan, Qiong and Min, Xiongkuo and Zhai, Guangtai and Lin, Weisi } ,
journal = { International Conference on Machine Learning (ICML) } ,
year = { 2024 } ,
institution = { Nanyang Technological University and Shanghai Jiao Tong University and Sensetime Research } ,
note = { Equal Contribution by Wu, Haoning and Zhang, Zicheng. Project Lead by Wu, Haoning. Corresponding Authors: Zhai, Guangtai and Lin, Weisi. }
}코드 아키텍처는 Basics에서 빌려줍니다. IQA-OPTIMATION, IMAGE-Quality-Assessment-Toolbox, PIQ, PIQA, CleanFid
또한 Musiq, DBCNN, NIMA, Hyperiqa, CNNIQA, Wadiqam, PIEAPP, PAQ2PIQ, MANIQA의 공개 저장소에도 감사드립니다.
궁금한 점이 있으면 [email protected] 으로 이메일을 보내주십시오