Bachelor Thesis: Increasing the Perceptual Image Quality of Adversarial Queries for Content-based Image Retrieval
This repository contains the source code of the pytorch implementation of "CV-PIRE" in my thesis. The thesis and the presentation I gave on this thesis is also included in the repository.
CV-PIRE was build on the code of PIRE [1].
CV-PIRE is tested on:
-
State-of-the-art CNN-based CBIR method GeM[2] with pre-trained ResNet-101-GeMsupports model and feature extraction codes provided by cnnimageretrieval-pytorch.
-
Off-the-shelf ResNet-101 pre-trained on ImageNet by replacing the original AvgPool2d with adaptiveAvgPool2d for allowing arbitrary size of the input image, and adding an additional L2N layer for feature normalization.
In order to generate adversarial queries for different models, please specific the parameter 'cnnmodel' when running the main file gen_pire.py
.
Python3
PyTorch 1.0.0
Both CPU and GPU supported
(Code tested with Python 3.6.6 on Ubuntu 16.04)
- Clone the code and put your own image queries in folder
./img_input/
.
git clone https://github.com/SamSweere/CV-PIRE
cd CV-PIRE
- To get the adversarial queries generated by the best-performed CV-PIRE (T = 100) in the thesis, please run:
python3 gen_cv_pire.py -T "100" -saveIter "100" -treshold "50" -kernelsize "5" -sigma "1" -gpu_id "-1" -cnnmodel "gem" -in_dir "./img_input/" -out_dir "./img_output/"
- Detailed explanation of CV-PIRE's parameters can be reached by:
python3 gen_cv_pire.py -h
The copyright of all the images belongs to the image owners.
[1] Z. Liu, Z. Zhao, and M. Larson, “Who’s afraid of adversarial queries? the impact of image modifications on content-based image retrieval,” in ACM International Conference on Multimedia Retrieval (ICMR), ACM, 2019.
[2] Radenović, Filip, Giorgos Tolias, and Ondrej Chum.
"Fine-tuning CNN image retrieval with no human annotation." IEEE Transactions on Pattern Analysis and Machine Intelligence (2018).