Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- V-FLUTE/.gitattributes +55 -0
- V-FLUTE/README.md +194 -0
- V-FLUTE/anno.py +198 -0
- V-FLUTE/images/test-00000-of-00002_102_b9950f69.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_106_dc55b240.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_112_66187cd2.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_120_78968076.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_121_6ab6c272.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_122_3f2e6acd.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_124_e546a6f6.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_127_0b381db1.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_128_b20054ed.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_135_a69e6917.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_142_35c445ce.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_144_83b586d8.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_155_c0a66edd.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_162_395721ca.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_164_ec67e40e.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_169_ff4627db.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_172_1c4590ee.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_173_18a5fd42.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_175_b465fe75.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_181_ab03b352.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_182_17665056.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_194_835af50f.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_199_35c2e336.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_212_99d3a8dc.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_214_c534177e.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_215_051b9106.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_216_bf4581f4.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_220_f39d2201.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_222_6d6fde0d.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_238_d9152c40.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_245_acc002d0.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_24_d4bddf3f.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_250_29f1e63c.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_25_aa10744d.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_263_d1fd18d9.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_265_df287a1f.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_266_abf54f79.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_270_58fadcef.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_277_aa2f9311.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_278_247fdae9.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_279_c8b18a07.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_27_0405e014.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_282_aabcc089.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_283_4b15735f.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_284_daedc4e7.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_291_565aef91.jpg +3 -0
- V-FLUTE/images/test-00000-of-00002_293_a37ef046.jpg +3 -0
V-FLUTE/.gitattributes
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.lz4 filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
# Audio files - uncompressed
|
| 38 |
+
*.pcm filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
*.sam filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
*.raw filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
# Audio files - compressed
|
| 42 |
+
*.aac filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
*.flac filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
*.ogg filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
# Image files - uncompressed
|
| 48 |
+
*.bmp filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
*.gif filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
*.tiff filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
# Image files - compressed
|
| 53 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
+
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
*.webp filter=lfs diff=lfs merge=lfs -text
|
V-FLUTE/README.md
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
dataset_info:
|
| 3 |
+
features:
|
| 4 |
+
- name: image
|
| 5 |
+
dtype: image
|
| 6 |
+
- name: claim
|
| 7 |
+
dtype: string
|
| 8 |
+
- name: label
|
| 9 |
+
dtype: string
|
| 10 |
+
- name: explanation
|
| 11 |
+
dtype: string
|
| 12 |
+
- name: phenomenon
|
| 13 |
+
dtype: string
|
| 14 |
+
- name: source_dataset
|
| 15 |
+
dtype: string
|
| 16 |
+
splits:
|
| 17 |
+
- name: train
|
| 18 |
+
num_bytes: 3655249408.996
|
| 19 |
+
num_examples: 4578
|
| 20 |
+
- name: validation
|
| 21 |
+
num_bytes: 556859385
|
| 22 |
+
num_examples: 726
|
| 23 |
+
- name: test
|
| 24 |
+
num_bytes: 575840194
|
| 25 |
+
num_examples: 723
|
| 26 |
+
download_size: 4768054820
|
| 27 |
+
dataset_size: 4787948987.996
|
| 28 |
+
configs:
|
| 29 |
+
- config_name: default
|
| 30 |
+
data_files:
|
| 31 |
+
- split: train
|
| 32 |
+
path: data/train-*
|
| 33 |
+
- split: validation
|
| 34 |
+
path: data/validation-*
|
| 35 |
+
- split: test
|
| 36 |
+
path: data/test-*
|
| 37 |
+
license: apache-2.0
|
| 38 |
+
task_categories:
|
| 39 |
+
- question-answering
|
| 40 |
+
- text-generation
|
| 41 |
+
language:
|
| 42 |
+
- en
|
| 43 |
+
tags:
|
| 44 |
+
- art
|
| 45 |
+
- figurative language
|
| 46 |
+
- visual metaphor
|
| 47 |
+
pretty_name: V-FLUTE
|
| 48 |
+
size_categories:
|
| 49 |
+
- 1K<n<10K
|
| 50 |
+
---
|
| 51 |
+
|
| 52 |
+

|
| 53 |
+
|
| 54 |
+
# Description
|
| 55 |
+
|
| 56 |
+
Large Vision-Language models (VLMs) have demonstrated strong reasoning capabilities in tasks requiring a fine-grained understanding of literal images and text, such as visual question-answering or visual entailment. However, there has been little exploration of these models' capabilities when presented with images and captions containing figurative phenomena such as metaphors or humor, the meaning of which is often implicit. To close this gap, we propose a new task and a high-quality dataset: Visual Figurative Language Understanding with Textual Explanations (V-FLUTE). We frame the visual figurative language understanding problem as an explainable visual entailment task, where the model has to predict whether the image (premise) entails a claim (hypothesis) and justify the predicted label with a textual explanation. Using a human-AI collaboration framework, we build a high-quality dataset, V-FLUTE, that contains 6,027 <image, claim, label, explanation> instances spanning five diverse multimodal figurative phenomena: metaphors, similes, idioms, sarcasm, and humor. The figurative phenomena can be present either in the image, the caption, or both.
|
| 57 |
+
|
| 58 |
+
# Paper
|
| 59 |
+
Pre-print is available here: https://arxiv.org/abs/2405.01474
|
| 60 |
+
|
| 61 |
+
# Citation
|
| 62 |
+
|
| 63 |
+
```
|
| 64 |
+
@misc{saakyan2024understandingfigurativemeaningexplainable,
|
| 65 |
+
title={Understanding Figurative Meaning through Explainable Visual Entailment},
|
| 66 |
+
author={Arkadiy Saakyan and Shreyas Kulkarni and Tuhin Chakrabarty and Smaranda Muresan},
|
| 67 |
+
year={2024},
|
| 68 |
+
eprint={2405.01474},
|
| 69 |
+
archivePrefix={arXiv},
|
| 70 |
+
primaryClass={cs.CL},
|
| 71 |
+
url={https://arxiv.org/abs/2405.01474},
|
| 72 |
+
}
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
Our dataset is based on significant amount of prior work. Please cite the following:
|
| 76 |
+
|
| 77 |
+
Please cite IRFL and Visual Metaphor datasets that provided images and captions:
|
| 78 |
+
|
| 79 |
+
IRFL:
|
| 80 |
+
|
| 81 |
+
```
|
| 82 |
+
@misc{yosef2023irfl, title={IRFL: Image Recognition of Figurative Language},
|
| 83 |
+
author={Ron Yosef and Yonatan Bitton and Dafna Shahaf},
|
| 84 |
+
year={2023},
|
| 85 |
+
eprint={2303.15445},
|
| 86 |
+
archivePrefix={arXiv},
|
| 87 |
+
primaryClass={cs.CL}
|
| 88 |
+
}
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
I Spy a Metaphor: Large Language Models and Diffusion Models Co-Create Visual Metaphors
|
| 92 |
+
|
| 93 |
+
```
|
| 94 |
+
@inproceedings{chakrabarty-etal-2023-spy,
|
| 95 |
+
title = "{I} Spy a Metaphor: Large Language Models and Diffusion Models Co-Create Visual Metaphors",
|
| 96 |
+
author = "Chakrabarty, Tuhin and
|
| 97 |
+
Saakyan, Arkadiy and
|
| 98 |
+
Winn, Olivia and
|
| 99 |
+
Panagopoulou, Artemis and
|
| 100 |
+
Yang, Yue and
|
| 101 |
+
Apidianaki, Marianna and
|
| 102 |
+
Muresan, Smaranda",
|
| 103 |
+
editor = "Rogers, Anna and
|
| 104 |
+
Boyd-Graber, Jordan and
|
| 105 |
+
Okazaki, Naoaki",
|
| 106 |
+
booktitle = "Findings of the Association for Computational Linguistics: ACL 2023",
|
| 107 |
+
month = jul,
|
| 108 |
+
year = "2023",
|
| 109 |
+
address = "Toronto, Canada",
|
| 110 |
+
publisher = "Association for Computational Linguistics",
|
| 111 |
+
url = "https://aclanthology.org/2023.findings-acl.465",
|
| 112 |
+
doi = "10.18653/v1/2023.findings-acl.465",
|
| 113 |
+
pages = "7370--7388",
|
| 114 |
+
abstract = "Visual metaphors are powerful rhetorical devices used to persuade or communicate creative ideas through images. Similar to linguistic metaphors, they convey meaning implicitly through symbolism and juxtaposition of the symbols. We propose a new task of generating visual metaphors from linguistic metaphors. This is a challenging task for diffusion-based text-to-image models, such as DALL$\cdot$E 2, since it requires the ability to model implicit meaning and compositionality. We propose to solve the task through the collaboration between Large Language Models (LLMs) and Diffusion Models: Instruct GPT-3 (davinci-002) with Chain-of-Thought prompting generates text that represents a visual elaboration of the linguistic metaphor containing the implicit meaning and relevant objects, which is then used as input to the diffusion-based text-to-image models. Using a human-AI collaboration framework, where humans interact both with the LLM and the top-performing diffusion model, we create a high-quality dataset containing 6,476 visual metaphors for 1,540 linguistic metaphors and their associated visual elaborations. Evaluation by professional illustrators shows the promise of LLM-Diffusion Model collaboration for this task.To evaluate the utility of our Human-AI collaboration framework and the quality of our dataset, we perform both an intrinsic human-based evaluation and an extrinsic evaluation using visual entailment as a downstream task.",
|
| 115 |
+
}
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
Please cite the following source that provides images and initial captions and explanations:
|
| 119 |
+
MemeCap: A Dataset for Captioning and Interpreting Memes
|
| 120 |
+
|
| 121 |
+
```
|
| 122 |
+
@inproceedings{hwang-shwartz-2023-memecap,
|
| 123 |
+
title = "{M}eme{C}ap: A Dataset for Captioning and Interpreting Memes",
|
| 124 |
+
author = "Hwang, EunJeong and
|
| 125 |
+
Shwartz, Vered",
|
| 126 |
+
editor = "Bouamor, Houda and
|
| 127 |
+
Pino, Juan and
|
| 128 |
+
Bali, Kalika",
|
| 129 |
+
booktitle = "Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing",
|
| 130 |
+
month = dec,
|
| 131 |
+
year = "2023",
|
| 132 |
+
address = "Singapore",
|
| 133 |
+
publisher = "Association for Computational Linguistics",
|
| 134 |
+
url = "https://aclanthology.org/2023.emnlp-main.89",
|
| 135 |
+
doi = "10.18653/v1/2023.emnlp-main.89",
|
| 136 |
+
pages = "1433--1445",
|
| 137 |
+
abstract = "Memes are a widely popular tool for web users to express their thoughts using visual metaphors. Understanding memes requires recognizing and interpreting visual metaphors with respect to the text inside or around the meme, often while employing background knowledge and reasoning abilities. We present the task of meme captioning and release a new dataset, MemeCap. Our dataset contains 6.3K memes along with the title of the post containing the meme, the meme captions, the literal image caption, and the visual metaphors. Despite the recent success of vision and language (VL) models on tasks such as image captioning and visual question answering, our extensive experiments using state-of-the-art VL models show that they still struggle with visual metaphors, and perform substantially worse than humans.",
|
| 138 |
+
}
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
Please cite the following data sources that provide images, captions, and explanations:
|
| 142 |
+
[Do Androids Laugh at Electric Sheep? Humor "Understanding" Benchmarks from The New Yorker Caption Contest](https://arxiv.org/abs/2209.06293)
|
| 143 |
+
|
| 144 |
+
```
|
| 145 |
+
@inproceedings{hessel2023androids,
|
| 146 |
+
title={Do Androids Laugh at Electric Sheep? {Humor} ``Understanding''
|
| 147 |
+
Benchmarks from {The New Yorker Caption Contest}},
|
| 148 |
+
author={Hessel, Jack and Marasovi{\'c}, Ana and Hwang, Jena D. and Lee, Lillian
|
| 149 |
+
and Da, Jeff and Zellers, Rowan and Mankoff, Robert and Choi, Yejin},
|
| 150 |
+
booktitle={Proceedings of the ACL},
|
| 151 |
+
year={2023}
|
| 152 |
+
}
|
| 153 |
+
```
|
| 154 |
+
|
| 155 |
+
Please also cite the following, from which the cartoons/captions New Yorker Caption contest dataset are derived:
|
| 156 |
+
|
| 157 |
+
```
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
@misc{newyorkernextmldataset,
|
| 161 |
+
author={Jain, Lalit and Jamieson, Kevin and Mankoff, Robert and Nowak, Robert and Sievert, Scott},
|
| 162 |
+
title={The {N}ew {Y}orker Cartoon Caption Contest Dataset},
|
| 163 |
+
year={2020},
|
| 164 |
+
url={https://nextml.github.io/caption-contest-data/}
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
@inproceedings{radev-etal-2016-humor,
|
| 168 |
+
title = "Humor in Collective Discourse: Unsupervised Funniness Detection in The {New Yorker} Cartoon Caption Contest",
|
| 169 |
+
author = "Radev, Dragomir and
|
| 170 |
+
Stent, Amanda and
|
| 171 |
+
Tetreault, Joel and
|
| 172 |
+
Pappu, Aasish and
|
| 173 |
+
Iliakopoulou, Aikaterini and
|
| 174 |
+
Chanfreau, Agustin and
|
| 175 |
+
de Juan, Paloma and
|
| 176 |
+
Vallmitjana, Jordi and
|
| 177 |
+
Jaimes, Alejandro and
|
| 178 |
+
Jha, Rahul and
|
| 179 |
+
Mankoff, Robert",
|
| 180 |
+
booktitle = "LREC",
|
| 181 |
+
year = "2016",
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
@inproceedings{shahaf2015inside,
|
| 185 |
+
title={Inside jokes: Identifying humorous cartoon captions},
|
| 186 |
+
author={Shahaf, Dafna and Horvitz, Eric and Mankoff, Robert},
|
| 187 |
+
booktitle={KDD},
|
| 188 |
+
year={2015},
|
| 189 |
+
}
|
| 190 |
+
```
|
| 191 |
+
|
| 192 |
+
# Acknowledgment
|
| 193 |
+
|
| 194 |
+
This research is supported in part by the Office of the Director of National Intelligence (ODNI), Intelligence Advanced Research Projects Activity (IARPA), via the HIATUS Program contract #2022-22072200005. The views and conclusions contained herein are those of the authors and should not be interpreted as necessarily representing the official policies, either expressed or implied, of ODNI, IARPA, or the U.S. Government. The U.S. Government is authorized to reproduce and distribute reprints for governmental purposes notwithstanding any copyright annotation therein.
|
V-FLUTE/anno.py
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import sys
|
| 4 |
+
import openai
|
| 5 |
+
import base64
|
| 6 |
+
import io
|
| 7 |
+
from PIL import Image
|
| 8 |
+
from datetime import datetime
|
| 9 |
+
import pytz
|
| 10 |
+
import time
|
| 11 |
+
|
| 12 |
+
# --- 配置區 (請根據您的環境修改) ---
|
| 13 |
+
|
| 14 |
+
# 1. vLLM 服務的地址和端口
|
| 15 |
+
VLLM_ENDPOINT = "http://localhost:1145/v1"
|
| 16 |
+
|
| 17 |
+
# 2. vLLM 加載的模型名稱 (!!!請務必修改為您的模型名稱!!!)
|
| 18 |
+
MODEL_NAME = "Qwen2.5-VL-72B"
|
| 19 |
+
|
| 20 |
+
# 3. 存放所有圖片的根文件夾路徑
|
| 21 |
+
IMAGE_BASE_DIR = Path("images")
|
| 22 |
+
|
| 23 |
+
# 4. 待處理和輸出的JSONL文件名
|
| 24 |
+
DATA_FILE = "muse_dataset.jsonl" # ⚠️ 請修改為您的JSONL文件名
|
| 25 |
+
|
| 26 |
+
# 5. 如果有處理失敗的記錄,記錄到這個文件
|
| 27 |
+
ERROR_LOG_FILE = "muse_annotation_errors.json"
|
| 28 |
+
|
| 29 |
+
# 6. 【新增】每處理多少條記錄就保存一次進度
|
| 30 |
+
SAVE_INTERVAL = 10
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
# --- 模型Prompt模板 (保持不變) ---
|
| 34 |
+
PROMPT_TEMPLATE = """# 角色
|
| 35 |
+
你是一位顶尖的认知科学家和视觉传达分析专家。你的任务是分析图像中所蕴含的深层、非字面含义,并解构理解它所需要的核心认知过程。
|
| 36 |
+
|
| 37 |
+
# 核心原则
|
| 38 |
+
你的分析**必须且只能**基于我提供的图像和以下上下文信息。**绝对禁止**你对图像进行任何独立的、额外的解读。
|
| 39 |
+
|
| 40 |
+
# 已知信息
|
| 41 |
+
以下是关于这张图片已经掌握的信息:
|
| 42 |
+
- **图像解释 (Explanation):** {explanation}
|
| 43 |
+
- **相关主张 (Claim):** {claim}
|
| 44 |
+
|
| 45 |
+
# 任务
|
| 46 |
+
根据提供的图像和上述已知信息,判断出理解这张图像的过程是否符合`parallel`(并行)理解路径。
|
| 47 |
+
|
| 48 |
+
# 认知路径定义与判断标准
|
| 49 |
+
请严格根据以下定义进行分类:
|
| 50 |
+
|
| 51 |
+
1. `direct` (直接通路):
|
| 52 |
+
* **判断标准:** 图像的含义是**约定俗成的、高度常规化的、一目了然的**。就像一个常见的成语或符号,观看者几乎不需要进行复杂的多步推理就能立刻理解。其“第一印象”就是正确的深层含义。
|
| 53 |
+
|
| 54 |
+
2. `sequential` (顺序解构通路):
|
| 55 |
+
* **判断标准:** 第一眼会有一个明显的、但可能是**片面的、不完整或需要被修正**的字面解读。随后通过深入思考或结合上下文,发现这个第一印象是错的或不完整的,然后才找到**最终预期的、较不凸显的深层含义**。这个过程包含一个“啊哈,原来是这样!”的顿悟。
|
| 56 |
+
|
| 57 |
+
3. `parallel` (并行通路):
|
| 58 |
+
* **判断标准:** 图像在第一眼观察时就能**同时且合理地引发两种或以上同样凸显的不同隐喻含义的理解**。这些理解角度都言之有理,在初次感知时便能同时被激活并保持激活状态。这些含义共同丰富了图像的信息,并且**没有一个被优先处理后又被拒绝的阶段**。
|
| 59 |
+
|
| 60 |
+
# 输出格式
|
| 61 |
+
你必须且只能返回一个合法的JSON对象,包含 `is_parallel` 和 `justification` 两个键。在JSON代码块前后不要添加任何其他文字。
|
| 62 |
+
{{
|
| 63 |
+
"is_parallel": true, // 或者 false
|
| 64 |
+
"justification": "请在此提供你的分析理由。如果为 true,请明确指出并存的两种或多种含义是什么。如果为 false,请说明它更符合顺序通路还是直接通路,并解释原因。"
|
| 65 |
+
}}
|
| 66 |
+
"""
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def encode_image_to_base64(image_path: Path) -> str:
|
| 70 |
+
# ... 此函數保持不變 ...
|
| 71 |
+
with Image.open(image_path) as img:
|
| 72 |
+
if img.mode != 'RGB':
|
| 73 |
+
img = img.convert('RGB')
|
| 74 |
+
buffer = io.BytesIO()
|
| 75 |
+
img.save(buffer, format="JPEG")
|
| 76 |
+
img_bytes = buffer.getvalue()
|
| 77 |
+
base64_str = base64.b64encode(img_bytes).decode('utf-8')
|
| 78 |
+
return f"data:image/jpeg;base64,{base64_str}"
|
| 79 |
+
|
| 80 |
+
def analyze_image_with_vllm(record: dict, image_path: Path):
|
| 81 |
+
# ... 此函數保持不變 ...
|
| 82 |
+
print(f"\n--- 正在分析圖片: {image_path.name} ---")
|
| 83 |
+
try:
|
| 84 |
+
extra_info = record.get("extra_info", {})
|
| 85 |
+
explanation = extra_info.get("explanation", "无")
|
| 86 |
+
claim = extra_info.get("claim", "无")
|
| 87 |
+
final_prompt = PROMPT_TEMPLATE.format(explanation=explanation, claim=claim)
|
| 88 |
+
base64_image = encode_image_to_base64(image_path)
|
| 89 |
+
vllm_client = openai.OpenAI(api_key="vllm", base_url=VLLM_ENDPOINT)
|
| 90 |
+
response = vllm_client.chat.completions.create(
|
| 91 |
+
model=MODEL_NAME,
|
| 92 |
+
messages=[{"role": "user", "content": [{"type": "text", "text": final_prompt}, {"type": "image_url", "image_url": {"url": base64_image}}]}],
|
| 93 |
+
max_tokens=4096, temperature=0.0
|
| 94 |
+
)
|
| 95 |
+
content = response.choices[0].message.content
|
| 96 |
+
cleaned_content = content.strip().lstrip('```json').rstrip('```').strip()
|
| 97 |
+
result_json = json.loads(cleaned_content)
|
| 98 |
+
if "is_parallel" in result_json and "justification" in result_json:
|
| 99 |
+
return result_json
|
| 100 |
+
else:
|
| 101 |
+
print(f"❌ 錯誤: 模型返回的JSON缺少 'is_parallel' 或 'justification' 鍵。")
|
| 102 |
+
return None
|
| 103 |
+
except FileNotFoundError:
|
| 104 |
+
print(f"❌ 錯誤: 圖片文件未找到 - {image_path}")
|
| 105 |
+
except json.JSONDecodeError:
|
| 106 |
+
print(f"❌ 錯誤: 模型返回的不是一個有效的JSON。")
|
| 107 |
+
print("原始模型響應:", content if 'content' in locals() else "無內容")
|
| 108 |
+
except Exception as e:
|
| 109 |
+
print(f"❌ 在分析 {image_path.name} 時發生未知錯誤: {e}")
|
| 110 |
+
return None
|
| 111 |
+
|
| 112 |
+
def save_all_records(records: list, file_path: Path):
|
| 113 |
+
"""【新增】一個獨立的保存函數"""
|
| 114 |
+
with open(file_path, 'w', encoding='utf-8') as f:
|
| 115 |
+
for record in records:
|
| 116 |
+
f.write(json.dumps(record, ensure_ascii=False) + '\n')
|
| 117 |
+
|
| 118 |
+
def main():
|
| 119 |
+
"""主函數,已重構以支持斷點續傳和定期保存"""
|
| 120 |
+
data_file = Path(DATA_FILE)
|
| 121 |
+
if not data_file.exists():
|
| 122 |
+
print(f"❌ 錯誤: 數據文件 '{DATA_FILE}' 不存在。")
|
| 123 |
+
return
|
| 124 |
+
|
| 125 |
+
# 獲取當前台灣時間
|
| 126 |
+
tz = pytz.timezone('Asia/Taipei')
|
| 127 |
+
current_time = datetime.now(tz).strftime('%Y年%m月%d日 晚上%H:%M')
|
| 128 |
+
print(f"--- 自動化標註腳本 (支持斷點續傳) ---")
|
| 129 |
+
print(f"現在是台灣時間: {current_time}")
|
| 130 |
+
|
| 131 |
+
# 1. 讀取所有數據到內存
|
| 132 |
+
with open(data_file, 'r', encoding='utf-8') as f:
|
| 133 |
+
records = [json.loads(line) for line in f]
|
| 134 |
+
|
| 135 |
+
total_records = len(records)
|
| 136 |
+
print(f"共找到 {total_records} 條記錄。開始檢查並處理...")
|
| 137 |
+
|
| 138 |
+
error_logs = []
|
| 139 |
+
skipped_count = 0
|
| 140 |
+
processed_count = 0
|
| 141 |
+
|
| 142 |
+
# 2. 遍歷記錄,調用模型並更新
|
| 143 |
+
for i, record in enumerate(records):
|
| 144 |
+
print(f"--- 檢查第 {i+1}/{total_records} 條記錄 ---")
|
| 145 |
+
|
| 146 |
+
# 【新增】斷點續傳的核心邏輯
|
| 147 |
+
# 檢查 justification 欄位是否已有內容
|
| 148 |
+
if record.get("extra_info", {}).get("justification"):
|
| 149 |
+
print(f" -> ⏭️ 已跳過 (justification已有內容)")
|
| 150 |
+
skipped_count += 1
|
| 151 |
+
continue
|
| 152 |
+
|
| 153 |
+
relative_path = record.get("image", {}).get("path")
|
| 154 |
+
if not relative_path:
|
| 155 |
+
print(" -> ⚠️ 警告: 記錄缺少圖片路徑,已跳過。")
|
| 156 |
+
error_logs.append({"record_index": i, "error": "Missing image path"})
|
| 157 |
+
continue
|
| 158 |
+
|
| 159 |
+
image_full_path = IMAGE_BASE_DIR / relative_path
|
| 160 |
+
|
| 161 |
+
analysis_result = analyze_image_with_vllm(record, image_full_path)
|
| 162 |
+
|
| 163 |
+
if analysis_result:
|
| 164 |
+
record["extra_info"]["justification"] = analysis_result.get("justification", "")
|
| 165 |
+
if analysis_result.get("is_parallel") is True:
|
| 166 |
+
record["extra_info"]["optimal_path"] = "parallel"
|
| 167 |
+
print(f" -> ✅ 成功標註: {image_full_path.name} -> parallel")
|
| 168 |
+
else:
|
| 169 |
+
record["extra_info"]["optimal_path"] = ""
|
| 170 |
+
print(f" -> ✅ 成功標註: {image_full_path.name} -> NOT parallel")
|
| 171 |
+
processed_count += 1
|
| 172 |
+
else:
|
| 173 |
+
print(f" -> ❌ 標注失敗,暫時跳過: {image_full_path.name}")
|
| 174 |
+
error_logs.append({"record_index": i, "path": relative_path, "error": "Analysis failed"})
|
| 175 |
+
|
| 176 |
+
# 【新增】定期保存進度的核心邏輯
|
| 177 |
+
# 每處理 SAVE_INTERVAL 條記錄(包括成功和失敗的)就保存一次
|
| 178 |
+
if (processed_count + len(error_logs)) > 0 and (processed_count + len(error_logs)) % SAVE_INTERVAL == 0:
|
| 179 |
+
save_all_records(records, data_file)
|
| 180 |
+
print(f"--- 💾 進度已保存 (已處理 {i+1}/{total_records} 條) ---")
|
| 181 |
+
|
| 182 |
+
# 3. 循環結束後,進行最終保存,確保所有更改都被寫入
|
| 183 |
+
print("\n--- 所有記錄檢查完畢,正在進行最終保存... ---")
|
| 184 |
+
save_all_records(records, data_file)
|
| 185 |
+
print(f"🎉 標註完成!最終數據已保存到: {data_file}")
|
| 186 |
+
|
| 187 |
+
if error_logs:
|
| 188 |
+
with open(ERROR_LOG_FILE, 'w', encoding='utf-8') as f:
|
| 189 |
+
json.dump(error_logs, f, indent=4)
|
| 190 |
+
print(f"⚠️ 處理過程中出現 {len(error_logs)} 個錯誤,詳情請查看 '{ERROR_LOG_FILE}'")
|
| 191 |
+
|
| 192 |
+
print(f"\n--- ✨ 本次運行總結 ✨ ---")
|
| 193 |
+
print(f"總計已跳過 (之前已完成): {skipped_count}")
|
| 194 |
+
print(f"總計新處理: {processed_count}")
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
if __name__ == '__main__':
|
| 198 |
+
main()
|
V-FLUTE/images/test-00000-of-00002_102_b9950f69.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_106_dc55b240.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_112_66187cd2.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_120_78968076.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_121_6ab6c272.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_122_3f2e6acd.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_124_e546a6f6.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_127_0b381db1.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_128_b20054ed.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_135_a69e6917.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_142_35c445ce.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_144_83b586d8.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_155_c0a66edd.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_162_395721ca.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_164_ec67e40e.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_169_ff4627db.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_172_1c4590ee.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_173_18a5fd42.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_175_b465fe75.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_181_ab03b352.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_182_17665056.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_194_835af50f.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_199_35c2e336.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_212_99d3a8dc.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_214_c534177e.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_215_051b9106.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_216_bf4581f4.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_220_f39d2201.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_222_6d6fde0d.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_238_d9152c40.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_245_acc002d0.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_24_d4bddf3f.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_250_29f1e63c.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_25_aa10744d.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_263_d1fd18d9.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_265_df287a1f.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_266_abf54f79.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_270_58fadcef.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_277_aa2f9311.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_278_247fdae9.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_279_c8b18a07.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_27_0405e014.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_282_aabcc089.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_283_4b15735f.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_284_daedc4e7.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_291_565aef91.jpg
ADDED
|
Git LFS Details
|
V-FLUTE/images/test-00000-of-00002_293_a37ef046.jpg
ADDED
|
Git LFS Details
|