Lancelot53 commited on
Commit
064ba00
·
verified ·
1 Parent(s): 187853a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +97 -3
README.md CHANGED
@@ -17,13 +17,13 @@ dataset_info:
17
  dtype: string
18
  splits:
19
  - name: train
20
- num_bytes: 145603.0
21
  num_examples: 4
22
  - name: test
23
- num_bytes: 15782648.0
24
  num_examples: 435
25
  download_size: 14338600
26
- dataset_size: 15928251.0
27
  configs:
28
  - config_name: default
29
  data_files:
@@ -31,4 +31,98 @@ configs:
31
  path: data/train-*
32
  - split: test
33
  path: data/test-*
 
 
 
 
 
 
 
 
34
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  dtype: string
18
  splits:
19
  - name: train
20
+ num_bytes: 145603
21
  num_examples: 4
22
  - name: test
23
+ num_bytes: 15782648
24
  num_examples: 435
25
  download_size: 14338600
26
+ dataset_size: 15928251
27
  configs:
28
  - config_name: default
29
  data_files:
 
31
  path: data/train-*
32
  - split: test
33
  path: data/test-*
34
+ task_categories:
35
+ - image-to-text
36
+ - visual-question-answering
37
+ - question-answering
38
+ language:
39
+ - en
40
+ size_categories:
41
+ - n<1K
42
  ---
43
+ # IllusionVQA: Optical Illusion Dataset
44
+
45
+ Paper Link: <br>
46
+ Github Link: <be>
47
+ ## TL;DR
48
+ IllusionVQA is a dataset of optical illusions and hard-to-interpret scenes designed to test the capability of Vision Language Models in comprehension and soft localization tasks. GPT4V achieved 62.99% accuracy on comprehension and 49.7% on localization, while humans achieved 91.03% and 100% respectively.
49
+
50
+ ## Usage
51
+ ```python
52
+ from datasets import load_dataset
53
+ import base64
54
+ from openai import OpenAI
55
+ import os
56
+ os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY"
57
+
58
+ def encode_image(pil_image):
59
+ temp_name = "temp.jpg"
60
+ pil_image.save(temp_name)
61
+ with open(temp_name, "rb") as image_file:
62
+ return base64.b64encode(image_file.read()).decode("utf-8")
63
+
64
+ def construct_mcq(options, correct_option):
65
+ correct_option_letter = None
66
+ i = "a"
67
+ mcq = ""
68
+ for option in options:
69
+ if option == correct_option:
70
+ correct_option_letter = i
71
+ mcq += f"{i}. {option}\n"
72
+ i = chr(ord(i) + 1)
73
+ mcq = mcq[:-1]
74
+ return mcq, correct_option_letter
75
+
76
+ def add_row(content, data, i, with_answer=False):
77
+ mcq, correct_option_letter = construct_mcq(data["options"], data["answer"])
78
+ content.append({ "type": "text",
79
+ "text": "Image "+str(i)+": "+data["question"]+"\n"+mcq })
80
+ content.append({ "type": "image_url",
81
+ "image_url": {"url": f"data:image/jpeg;base64,{encode_image(data["image"])}",
82
+ "detail": "low"}})
83
+ if with_answer:
84
+ content.append({"type": "text", "text": "Answer {}: ".format(i)+correct_option_letter})
85
+ else:
86
+ content.append({"type": "text", "text": "Answer {}: ".format(i), })
87
+ return content
88
+
89
+ dataset = load_dataset("csebuetnlp/illusionVQA-Comprehension")
90
+ client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
91
+
92
+ content = [{
93
+ "type": "text",
94
+ "text": "You'll be given an image, an instruction and some choices. You have to select the correct one. Do not explain your reasoning. Answer with the option's letter from the given choices directly. Here are a few examples:",
95
+ }]
96
+
97
+ ### Add the few examples
98
+ i = 1
99
+ for data in dataset["train"]:
100
+ content = add_row(content, data, i, with_answer=True)
101
+ i += 1
102
+
103
+ content.append({"type": "text","text": "Now you try it!",})
104
+ next_idx = i
105
+
106
+ ### Add the test data
107
+ test_data = dataset["test"][0]
108
+ content_t = add_row(content.copy(), test_data, next_idx, with_answer=False)
109
+
110
+ ### Get the answer from GPT-4
111
+ response = client.chat.completions.create(
112
+ model="gpt-4-vision-preview",
113
+ messages=[{"role": "user","content": content_t,}],
114
+ max_tokens=5,
115
+ )
116
+ gpt4_answer = response.choices[0].message.content
117
+ print(gpt4_answer)
118
+ ```
119
+
120
+ ## License
121
+ This dataset is made available for non-commercial research purposes only, including for evaluation of model performance. The dataset may not be used for training models. The dataset contains images collected from the internet. While permission has been obtained from some of the images' creators, permission has not yet been received from all creators. If you believe any image in this dataset is used without proper permission and you are the copyright holder, please email [email protected] to request the removal of the image from the dataset.
122
+
123
+ The dataset creator makes no representations or warranties regarding the copyright status of the images in the dataset. The dataset creator shall not be held liable for any unauthorized use of copyrighted material that may be contained in the dataset.
124
+
125
+ You agree to the terms and conditions specified in this license by downloading or using this dataset. If you do not agree with these terms, do not download or use the dataset.
126
+
127
+
128
+ ### Citation