Paper Info
- Accepted on ECCV 2022
- Authors: Roni Paiss, Hila Chefer, Lior Wolf
- Affiliation: Tel Aviv Uni, Apple
- arXiv link: https://arxiv.org/abs/2204.04908
- Task: zero-shot CLIP을 objective로 사용하는 latent optimization
- few-shot prompt image classification
- zero-shot text-guided image editing
- zero-shot text-to-image with spatial conditioning - TLDR: CLIP의 similarity loss에 XAI-based loss를 추가하여, CLIP이 가지고 있는 한계점을 극복
1. Brief Summary
latent optimization에서 zero-shot CLIP score을 objective로 사용하면 2가지 문제가 있음
기존 연구들은 사용할 input text를 carefully tune하던지, 혹은 latent optimization 방식을 사용하지 않았음
해당 논문은 CLIP이 어디에 focus 해야하는지를 알려주는 XAI-based loss를 추가하여 문제를 해결함
문제 1
input text가 제대로 반영되지 않은 image가 생성됨
원인 1
CLIP은 input text의 phrasing에 unstable하다는 instability issue가 있음
이로 인해, CLIP similarity loss로 latent를 optimize하면 sub-optimal에 빠질 수 있음
즉, input text 중 일부만을 보고 latent가 optimize되어 문제가 생기게 된 것
해결 1
CLIP이 input text의 모든 semantic words를 보도록 하면 해결할 수 있음
text relevance score을 이용한 explainability loss를 추가하여 이를 해결
문제 2
input text 내의 spatial condition이 제대로 반영되지 않은 image가 생성됨
원인 2
CLIP이 학습한 데이터로 인해, CLIP은 input간에 matching entity간의 existence를 중요하게 생각하지 position을 중요하게 생각하지 않음
해결 2
먼저 spatial condition이 있는 input text를 bounding box와 그에 해당하는 text로 나눔
CLIP이 주어진 text에 대해 상응하는 bounding box를 보도록 하면 해결할 수 있음
image relevance score와 bounding box간의 Dice loss를 accumulate한 IoU loss를 추가하여 이를 해결
2. Method
2.1. Explainability
결국 relevancy map이란, CLIP이 각 input tokens를 얼마나 focus했는지를 측정한 것
relevancy map을 기반으로 each input token에 대한 relevance score을 구할 수 있음
word를 구성하는 tokens의 relevance score의 max 값을 이용하여 word의 relevance score를 구함
2.2. Prompt engineering
- Context Optimization (CoOp)



CLIP image encoder, text encoder는 frozen
n-shot data가 주어졌을 때, 정답 class에 대한 likelihood가 maximize하도록 learnable context를 학습
(Equation 1이 maximize되도록 학습, t(c) : textual template of class c)
여기서 learnable context라는 것은 text가 아니라 벡터이기에, 단순하게 backprop으로 학습
- explainability loss
CLIP score가 class name을 보고 optimize하면 CoOp이 sub-optimal로 빠지는 것을 방지할 수 있음
(learned context만 보고 similarity loss가 optimize되는 것을 방지)
이를 위해 text relevance score을 기반으로 explainability loss를 설계
분자 : text template 중 class label에 해당하는 words의 relevancy score 중 max
분모 : text template 중 class label을 제외한 모든 words의 relevancy score의 합
score가 높다 → CLIP이 class label text를 보고 similarity score을 계산함
score가 낮다 → CLIP이 class label text를 보지 않고 similarity score을 계산함
explainability score는 text prompt 내의 다른 word에 비해 class name 가 CLIP score에 미친 영향력을 측정함
explainability loss는 ground truth class에 대한 explainability score는 높아지도록, 다른 class에 대한 explainability score는 낮아지도록 만들어줌
2.3. Zero-shot text-guided image manipulation
- StyleCLIP


StyleCLIP 논문에서는 3가지 방식의 text-based image editing 방식을 제안함
(latent optimization, mapper training, global directions extraction)
latent optimization을 제외한 2가지 방식은 모델을 학습을 해야함
해당 논문은 zero-shot method에만 관심이 있기에, latent optimization 방법만 실험
(input image에 대한 latent code를 directly optimize하여 text에 맞는 image를 생성하는 방식)
- explainability loss
CLIP이 input text의 모든 semantic meaning을 보도록 하면 local minima에 빠지는 것을 방지할 수 있음
이를 위해 text relevance score을 기반으로 explainability loss를 설계
input text query에서 semantic words의 집합 S를 구한 뒤, S의 원소에 대한 relevance score가 maximize되도록 설계
2.4. Zero-shot text-to-image with spatial conditioning
- VQGAN-CLIP


1. VQGAN encoder를 통해 input image로부터 z-vector를 구함
2. VQGAN decoder를 통해 z-vector로부터 generated image를 구함
3. Augmentation을 통해 generated image로부터 augmented images를 구함
4. Augmented images와 text prompt간의 CLIP similarity score을 구함
5. Similarity loss + z-vector에 대한 L2 regularization loss를 통해 loss를 구함
6. Loss가 minimize되도록 z-vector를 backprop으로 update
Task가 zero-shot text-to-image이기에, 1번 과정 대신 random Gaussian에서 sampling하여 z-vector initialize
(text가 주어졌을 때 image를 생성하는 task이기에, input image가 필요 없음)
- IoU loss
먼저 spatial conditioning이 있는 text를 (bounding box, bounding box 안에 생성할 text) pair로 변환
(spatial condition에 해당하는 text를 bounding box로 변환한다는 의미)
CLIP이 bounding box에 해당하는 영역을 보고 text와의 similarity를 높이도록 IoU loss를 설계
3. Experiments
3.1. One-shot prompt engineering
다양한 backbone, CoOp hyperparameter에 대해 실험한 결과, explainability loss를 추가한게 더 좋음
3.2. Zero-shot text-guided image manipulation
Quality : text prompt와 manipulation 결과간의 similarity
Identity : manipulation 결과가 identity를 얼마나 잘 보존했는지
전반적으로 Quality와 Identity간의 trade-off가 있는 것을 확인할 수 있음
StyleCLIP은 identity는 잘 보존하지만 text prompt를 잘 반영하지 않으며, explainability loss를 추가하면 identity는 조금 다르지만 text prompt의 semantic을 잘 반영함
저자들이 분석한 결과, input image의 gender를 바꾸는 prompt에 대해 identity gap이 더욱 컸다고 함
(e.g. women image with text prompt 'A man with a beard', 'A blond man')
3.3. Zero-shot text-to-image with spatial conditioning
Textual conditioning: CLIP(i, t)
Similarity-based: CLIP(i_j, t_j) → bounding box 이외의 masked image i_j와 t_j 간의 similarity loss
Similarity-based 2: CLIP(i, t_j) + CLIP(i_j, t_j)
ours: CLIP(i, t_j) + IoU loss
Precision, Recall
각 method별로 image generation
each text description에 대한 image patch의 explainability map 생성
Otsu's method를 이용하여 explainability map을 binarize
binarized maps와 gt간의 precision, recall, F1 score 측정
AP, AR
각 method별로 image generation
DETR을 이용하여 object detection
detected bounding box와 gt간의 AP, AR 측정
baseline (textual conditioning, similarity-based, similarity-based 2)는 bounding box 이외의 공간에도 object를 생성함
IoU loss를 추가하면 bounding box 안에만 object를 잘 생성함
4. Conclusions
The author's conclusions
CLIP이 어디에 집중해야하는가를 알려주어, 모델 학습이 필요 없는 zero-shot 성능을 높일 수 있음
하지만, supervised에 비해서 성능이 부족한 건 어쩔 수 없음
My Conclusion
해당 논문에서 아쉬웠던 부분을 꼽자면 다음과 같음
- [문제에 대한 실험] 논문에서 제시한 CLIP의 2가지 문제점에 대한 실험이 없음
- [기존 연구와의 비교] "carefully tuned input text" vs "not-tuned input text + explainability loss" 성능 비교가 없음
- [실험 다양성] image editing task에서 semantic words가 많은 long input text에 대한 결과가 없음
- [실험 엄밀성] image editing task에서 human evaluation 이외의 quantitative 지표가 없음
그럼에도 불구하고, 해당 논문의 컨셉 자체는 워낙 직관적이고 기존 연구들로부터 잘된다는 것이 널리 알려진 방법임
(multi-task loss를 통해 generalization 성능을 높임)
XAI와 CLIP을 섞은 것이 흥미로웠으며, 해당 컨셉은 충분히 다양한 연구에서 활용할만할듯
Rating
Good
5. Extra
Reference 1: [ICCV 2021] Generic Attention-model Explainability for Interpreting Bi-Modal and Encoder-Decoder Transformers
Reference 2: [IJCV 2022] Learning to Prompt for Vision-Language Models
Reference 3: [ICCV 2021 Oral] StyleCLIP: Text-Driven Manipulation of StyleGAN Imagery
Reference 4: [ECCV 2022] VQGAN-CLIP: Open Domain Image Generation and Editing with Natural Language Guidance