# https://raw.githubusercontent.com/YanNeu/RePOPE/refs/heads/main/annotations/coco_repope_random.json # https://raw.githubusercontent.com/YanNeu/RePOPE/refs/heads/main/annotations/coco_repope_adversarial.json # https://raw.githubusercontent.com/YanNeu/RePOPE/refs/heads/main/annotations/coco_repope_popular.json ## example in json: # coco_repope_random.json # {"question_id": 1, "image": "COCO_val2014_000000310196.jpg", "text": "Is there a snowboard in the image?", "label": "yes"} # coco_repope_adversarial.json # {"question_id": 1, "image": "COCO_val2014_000000210789.jpg", "text": "Is there a truck in the image?", "label": "yes"} from datasets import load_dataset ds = load_dataset("lmms-lab/POPE", "default")['test'] # sample entry: # {'id': '0', 'question_id': '1', 'question': 'Is there a snowboard in the image?', # 'answer': 'yes', 'image_source': 'COCO_val2014_000000310196', # 'image': , # 'category': 'adversarial'} # --------------------------------------------------------------------------- # helper: pull annotations from remote JSONs and attach to examples # --------------------------------------------------------------------------- import requests annotation_urls_jsonl = [ "https://raw.githubusercontent.com/YanNeu/RePOPE/refs/heads/main/annotations/coco_repope_random.json", "https://raw.githubusercontent.com/YanNeu/RePOPE/refs/heads/main/annotations/coco_repope_adversarial.json", "https://raw.githubusercontent.com/YanNeu/RePOPE/refs/heads/main/annotations/coco_repope_popular.json", ] # JSON filenames encode the category we want to propagate # load and index by category, subdividing by question_id # build a lookup index from category and question_id to annotation import os repope_index = {} for url in annotation_urls_jsonl: basename = os.path.splitext(os.path.basename(url))[0] # e.g. coco_repope_random category = basename.split("_")[-1] r = requests.get(url) r.raise_for_status() for line in r.text.splitlines(): if not line.strip(): continue ann = requests.compat.json.loads(line) ann["source_category"] = category qid = str(ann.get("question_id")) repope_index.setdefault(category, {})[qid] = ann # iterate once, updating answers and gathering statistics count = changed = removed = 0 new_examples = [] for idx, example in enumerate(ds): qid = str(example.get("question_id")) ann = repope_index.get(example.get("category"), {}).get(qid) if not ann: print(f"⚠️ No annotation for idx={idx} qid={qid} category={example.get('category')}") removed += 1 continue example['pope_old_answer'] = example['answer'] if example['answer'] != ann['label']: example['answer'] = ann['label'] changed += 1 new_examples.append(example) count += 1 print(f"✅ Matched {count} examples.") print(f"🔄 Changed {changed} answers.") print(f"❌ Removed {removed} with no annotation.") print("inspection complete") # ✅ Matched 8185 examples. # 🔄 Changed 494 answers. # ❌ Removed 815 with no annotation. from datasets import Dataset, DatasetDict ds = Dataset.from_list(new_examples) dataset = DatasetDict({ "test": ds}) dataset.push_to_hub("SushantGautam/RePOPE")