RepositoryPythonITItaly
miccunifi

miccunifi/QualiCLIP

Quality-Aware Image-Text Alignment for Opinion-Unaware Image Quality Assessment

134stars
4forks
1issues
1views

QualiCLIP

Quality-Aware Image-Text Alignment for Opinion-Unaware Image Quality Assessment

arXiv GitHub Stars

🔥🔥🔥 [2025/01/15] QualiCLIP is now included in the IQA-PyTorch GitHub Stars library

This is the official repository of the paper "Quality-Aware Image-Text Alignment for Opinion-Unaware Image Quality Assessment".

[!NOTE] If you are interested in IQA, take a look at our new dataset with UHD images and our self-supervised NR-IQA model

Overview

Abstract

No-Reference Image Quality Assessment (NR-IQA) focuses on designing methods to measure image quality in alignment with human perception when a high-quality reference image is unavailable. Most state-of-the-art NR-IQA approaches are opinion-aware, i.e. they require human annotations for training. This dependency limits their scalability and broad applicability. To overcome this limitation, we propose QualiCLIP (Quality-aware CLIP), a CLIP-based self-supervised opinion-unaware approach that does not require human opinions. In particular, we introduce a quality-aware image-text alignment strategy to make CLIP generate quality-aware image representations. Starting from pristine images, we synthetically degrade them with increasing levels of intensity. Then, we train CLIP to rank these degraded images based on their similarity to quality-related antonym text prompts. At the same time, we force CLIP to generate consistent representations for images with similar content and the same level of degradation. Our experiments show that the proposed method improves over existing opinion-unaware approaches across multiple datasets with diverse distortion types. Moreover, despite not requiring human annotations, QualiCLIP achieves excellent performance against supervised opinion-aware methods in cross-dataset experiments, thus demonstrating remarkable generalization capabilities.

Overview of the proposed quality-aware image-text alignment strategy. Starting from a pair of two random overlapping crops from a pristine image, we synthetically degrade them with $L$ increasing levels of intensity, resulting in $L$ pairs. Then, given two quality-related antonym prompts $T_p$ and $T_n$, we fine-tune CLIP's image encoder with three margin ranking losses ($L_{cons}$, $L_{pos}$, $L_{neg}$) by considering the similarity between the prompts and the degraded crops. Specifically, we use $L_{cons}$ to force CLIP to generate consistent representations for the crops belonging to each pair, since they exhibit similar content and the same degree of distortion. At the same time, we make the similarity between the prompt $T_p$ (or $T_n$) and the increasingly degraded versions of the crops correlate inversely (or directly) with the intensity of the distortion through $L_{pos}$ (or $L_{neg}$).

Citation

@article{agnolucci2024qualityaware,
      title={Quality-Aware Image-Text Alignment for Opinion-Unaware Image Quality Assessment}, 
      author={Agnolucci, Lorenzo and Galteri, Leonardo and Bertini, Marco},
      journal={arXiv preprint arXiv:2403.11176},
      year={2024}
}

Usage

Minimal Working Example

Thanks to torch.hub, you can use our model for inference without the need to clone our repo or install any specific dependencies. QualiCLIP outputs a quality score in the range [0, 1], where higher is better.

import torch
import torchvision.transforms as transforms
from PIL import Image

# Set the device
device = torch.device("cuda") if torch.cuda.is_available() else "cpu"

# Load the model
model = torch.hub.load(repo_or_dir="miccunifi/QualiCLIP", source="github", model="QualiCLIP")
model.eval().to(device)

# Define the preprocessing pipeline
preprocess = transforms.Compose([
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.48145466, 0.4578275, 0.40821073], std=[0.26862954, 0.26130258, 0.27577711]),
])

# Load the image
img_path = "<path_to_your_image>"
img = Image.open(img_path).convert("RGB")

# Preprocess the image
img = preprocess(img).unsqueeze(0).to(device)

# Compute the quality score
with torch.no_grad(), torch.cuda.amp.autocast():
    score = model(img)

print(f"Image quality score: {score.item()}")

Getting Started

Installation

We recommend using the Anaconda package manager to avoid dependency/reproducibility problems. For Linux systems, you can find a conda installation guide here.

  1. Clone the repository
git clone https://github.com/miccunifi/QualiCLIP
  1. Install Python dependencies
conda create -n QualiCLIP -y python=3.10
conda activate QualiCLIP
cd QualiCLIP
chmod +x install_requirements.sh
./install_requirements.sh

Single Image Inference

To get the quality score of a single image, run the following command:
python single_image_inference.py --img_path assets/01.png
--img_path                  Path to the image to be evaluated

QualiCLIP outputs a quality score in the range [0, 1], where higher is better.

To be released

  • Pre-trained model
  • Testing code
  • Training code

Authors

LICENSE

Creative Commons License
All material is made available under Creative Commons BY-NC 4.0. You can use, redistribute, and adapt the material for non-commercial purposes, as long as you give appropriate credit by citing our paper and indicate any changes that you've made.

Similar Projects

Discover other similar projects and AI models.

RepositoryPython
miccunifi/ARNIQA

[WACV 2024 Oral] - ARNIQA: Learning Distortion Manifold for Image Quality Assessment

159
Jun 18, 2026
RepositoryC++
opencv/opencv

Open Source Computer Vision Library

91.8k
Nov 30, 2026
RepositoryPython
pavancm/CONTRIQUE

Official implementation for "Image Quality Assessment using Contrastive Learning"

141
Jun 18, 2024
RepositoryPython
d2l-ai/d2l-zh

《动手学深度学习》:面向中文读者、能运行、可讨论。中英文版被70多个国家的500多所大学用于教学。

82.9k
Jul 30, 2024
RepositoryPython
rohitg00/ai-engineering-from-scratch

Learn AI Engineering! Learn it. Build it. Ship it for others.

81.4k
Nov 30, 2026
RepositoryMATLAB
dsoellinger/blind_image_quality_toolbox

Collection of Blind Image Quality Metrics in Matlab

167
Jun 27, 2020
RepositoryPython
ultralytics/yolov5

Ultralytics YOLOv5 in PyTorch for object detection, instance segmentation, classification, training, and export.

58.3k
Nov 23, 2026
RepositoryPython
roboflow/supervision

We write your reusable computer vision tools. 💜

51.7k
Nov 27, 2026
RepositoryPython
kornia/kornia

🐍 Geometric Computer Vision Library for Spatial AI

12.5k
Nov 30, 2026