Coder Social home page Coder Social logo

mapleiqa's Introduction

MaPLe-IQA - A deep learning model for blind image quality assessment.

Paper

A deep learning models for blind image quality assessment based on MaPLe(Multimodal Promt Learning), a CLIP based model with added coupling function for performance enhancement.

Quickstart

This is a quickstart guide to use MaPLe-IQA for quick deployment

Step 1: Install the repository as a package

$ conda install --yes -c pytorch pytorch=1.7.1 torchvision cudatoolkit=11.0
$ pip install ftfy regex tqdm scipy pandas
$ pip install git+https://github.com/luutn2002/mapleiqa.git

Step 2: Create a .ini file for model config

import configparser
import os
from torch.cuda import is_available

#Script used to create configuration for models.

config = configparser.ConfigParser()
TEST_MODEL_NAME = 'mapleiqa'
DEVICE = "cuda:0" if is_available() else "cpu"

config['MODEL_CONFIG'] = {
  'MAPLE_PROMPT_DEPTH' : 9,
  'MAPLE_INPUT_SIZE' : (224, 224),
  'MAPLE_N_CTX' : 2,
  'MAPLE_CTX_INIT' : "This is a ",
  'MAPLE_PRETRAIN_DIR' : './model.pth.tar-5',
  'MAPLE_POS_EMBED' : True,
  'MAPLE_INNER_BATCH' : 12,
  'BACKBONE' : 'ViT-B/32',
  'DEVICE' : DEVICE,
  'MODEL': 'MaPLeIQA',
  'FREEZE_IMAGE_ENCODER': False,
  'FREEZE_TEXT_ENCODER': False
}

with open(f"./configs/{config['DEFAULT']['TEST_MODEL_NAME']}.ini", 'w') as configfile:
  config.write(configfile)

Your .ini file should look like this:

[MODEL_CONFIG]
maple_prompt_depth = 9
maple_input_size = (224, 224)
maple_n_ctx = 2
maple_ctx_init = This is a 
maple_pos_embed = True
maple_inner_batch = 12
backbone = ViT-B/32
device = cuda:0
model = MaPLeIQA
freeze_image_encoder = False
freeze_text_encoder = False

Step 3: Include model in your code

from mapleiqa.models import build_mapleiqa
import torch

model = build_mapleiqa(["good photo", "bad photo"], #List of prompts equivalent to number of MaPLe models being used
                       "MaPLeIQA", 
                       "./configs/mapleiqa.ini")

ckpt = torch.load("./checkpoint_sample_2.pt") #Pretrained checkpoint
model.load_state_dict(ckpt['model_state_dict']) #Load our pretrained models if you prefer

Download our pretrained model here. Check our example scripts for more details on how we train the model.

Result with datasets

Datasets SROCC PLCC
KonIQ-10K 0.648 0.701
TID 2008 0.934 0.929
SPAQ 0.796 0.801
TID 2013 0.912 0.914
LIVE 0.560 0.583
KADID-10K 0.930 0.926

Notes: Datasets are train all at once in sequentials.

Citation

@INPROCEEDINGS{10402183,
  author={Luu, Nhan T. and Onuoha, Chibuike and Thang, Truong Cong},
  booktitle={2023 IEEE 15th International Conference on Computational Intelligence and Communication Networks (CICN)}, 
  title={Blind Image Quality Assessment With Multimodal Prompt Learning}, 
  year={2023},
  pages={614-618},
  doi={10.1109/CICN59264.2023.10402183}}

mapleiqa's People

Contributors

luutn2002 avatar kobejean avatar trinh3121 avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.