Coder Social home page Coder Social logo

pg-ia-nilut's Introduction

Prompt-Guided Image-Adaptive Neural Implicit Lookup Tables for Interpretable Image Enhancement

This is the official implementation of the paper in ACM Multimedia 2024. [paper]

Code Structure

This code is primarily based on AdaInt. The most significant modification is in adaint/model.py.

  • mmedit/: MMEditing toolbox. Some modifications are made to use CLIP based on CLIP-IQA.
  • adaint/: the core implementation of the paper, including:
    • annfiles/: including the annotation files for FiveK and PPR10K datasets.
    • dataset.py: the dataset class (FiveK and PPR10K).
    • transforms.py: including some augmentations not provided by MMEditing toolbox.
    • ailut_transform/: the implementation of the Lookup function.
    • model.py: the implementation of the IA-NILUT and the prompt guidance loss.
    • configs/: including configurations to conduct experiments.
  • pretrained/: including the pretrained models.

Requirements

  • Python 3.7.11
  • CUDA 11.3

Install the Python libraries:

conda install pytorch==1.11.0 torchvision==0.12.0 cudatoolkit=11.3 -c pytorch
pip install mmcv-full==1.6.0 -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.11.0/index.html
pip install -r requirements.txt

Set up the MMEditing toolbox:

pip install -v -e .

Compile and install the extension:

python adaint/ailut_transform/setup.py install

Datasets

The paper uses the FiveK and PPR10K datasets for experiments. It is recommended to refer to the dataset creators first using the above two urls.

The preparation of the datasets followed the procedures outlined in AdaInt. Please refer to that source for details.

Usage

Training

Our training is divided into three stages.

  • The first training step
(FiveK) python tools/train.py adaint/configs/fivekrgb_first.py
(PPR10K) python tools/train.py adaint/configs/ppr10k_a_first.py
  • The second training step
(FiveK) python tools/train.py adaint/configs/fivekrgb_second.py
(PPR10K) python tools/train.py adaint/configs/ppr10k_a_second.py
  • The third training step
    • Before conducting the third training step, please check the log file from the second training step (work_dirs/pg_ia_nilut_fivekrgb_second/XXX.log or work_dirs/pg_ia_nilut_ppr10k_a_second/XXX.log). Find the model with the best PSNR and set its path as pretrained_PG_IA_NILUT_path in adaint/configs/fivekrgb_third.py or adaint/configs/ppr10k_a_third.py.
(FiveK) python tools/train.py adaint/configs/fivekrgb_third.py
(PPR10K) python tools/train.py adaint/configs/ppr10k_a_third.py

Testing

We provide pretrained models in ./pretrained/. To conduct testing, please use the following commands:

(FiveK) python tools/test.py adaint/configs/fivekrgb_third.py pretrained/fivekrgb.pth --save-path [PATH/TO/SAVE/RESULTS]
(PPR10K) python tools/test.py adaint/configs/ppr10k_a_third.py pretrained/ppr10k_a.pth --save-path [PATH/TO/SAVE/RESULTS]

If you want to visualize the filter effects, please use the --visualize option:

(FiveK) python tools/test.py adaint/configs/fivekrgb_third.py pretrained/fivekrgb.pth --save-path [PATH/TO/SAVE/RESULTS] --visualize
(PPR10K) python tools/test.py adaint/configs/ppr10k_a_third.py pretrained/ppr10k_a.pth --save-path [PATH/TO/SAVE/RESULTS] --visualize

Demo

We provide demo codes for a CPU machine. It is assumed that this code is executed in a different environment from the one above. You need to install libraries for demo.

Install the Python libraries:

pip install torch==1.11.0 torchvision==0.12.0 --extra-index-url https://download.pytorch.org/whl/cpu
pip install mmcv-full==1.6.0 -f https://download.openmmlab.com/mmcv/dist/cpu/torch1.11.0/index.html
pip install -r requirements_demo.txt

Set up the MMEditing toolbox:

pip install -v -e .

Compile and install the extension:

python adaint/ailut_transform/setup_demo.py install

To run the demo, please use the following command:

python tools/demo.py pretrained/fivekrgb.pth resources/a3433.jpg

The following windows will be displayed.

demo

Acknowledgements

Our implementation is based on the following codes. We would like to thank them.

Citation

If you find our research useful in your research, please consider citing:

@inproceedings{kosugi2024prompt,
    title={Prompt-Guided Image-Adaptive Neural Implicit Lookup Tables for Interpretable Image Enhancement},
    author={Kosugi, Satoshi},
    booktitle={ACM Multimedia},
    year={2024}
}

pg-ia-nilut's People

Contributors

satoshi-kosugi 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.