renyunli0116 commited on
Commit
5e0d0d9
·
verified ·
1 Parent(s): 68523c9

Delete convert4json_ScanQA.ipynb

Browse files
Files changed (1) hide show
  1. convert4json_ScanQA.ipynb +0 -89
convert4json_ScanQA.ipynb DELETED
@@ -1,89 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "markdown",
5
- "metadata": {},
6
- "source": [
7
- "This file is to convert ScanQA to LLaVA-3D dataset format. Ref: https://github.com/ZCMax/LLaVA-3D/issues/5"
8
- ]
9
- },
10
- {
11
- "cell_type": "code",
12
- "execution_count": 2,
13
- "metadata": {},
14
- "outputs": [],
15
- "source": [
16
- "# load json and show\n",
17
- "import json\n",
18
- "import os\n",
19
- "\n",
20
- "data = json.load(open('ScanQA_v1.0_train.json'))\n",
21
- "# print(json.dumps(data, indent=4))\n",
22
- "\n",
23
- "# {\"answers\": [\"brown cabinet with tv sitting in it\"], \n",
24
- "# \"object_ids\": [8], \n",
25
- "# \"object_names\": [\"cabinet\"], \n",
26
- "# \"question\": \"What is in the right corner of room by curtains?\", \n",
27
- "# \"question_id\": \"train-scene0000-0\", \n",
28
- "# \"scene_id\": \"scene0000_00\"},\n"
29
- ]
30
- },
31
- {
32
- "cell_type": "code",
33
- "execution_count": 3,
34
- "metadata": {},
35
- "outputs": [],
36
- "source": [
37
- "import json\n",
38
- "\n",
39
- "# Read the input JSON file\n",
40
- "with open('ScanQA_v1.0_train.json', 'r') as f:\n",
41
- " data = json.load(f)\n",
42
- "\n",
43
- "output = []\n",
44
- "\n",
45
- "for entry in data:\n",
46
- " conversation = {\n",
47
- " \"id\": entry['object_ids'][0],\n",
48
- " \"video\": f\"scannet/{entry['scene_id']}\",\n",
49
- " \"conversations\": [\n",
50
- " {\n",
51
- " \"from\": \"human\",\n",
52
- " \"value\": f\"<video>\\n{entry['question']}\"\n",
53
- " },\n",
54
- " {\n",
55
- " \"from\": \"gpt\",\n",
56
- " \"value\": entry['answers'][0].capitalize() + '.'\n",
57
- " }\n",
58
- " ]\n",
59
- " }\n",
60
- " output.append(conversation)\n",
61
- "\n",
62
- "# Write the output to a JSON file\n",
63
- "with open('LLaVA_canQA_v1.0_train.json', 'w') as f:\n",
64
- " json.dump(output, f, indent=4)"
65
- ]
66
- }
67
- ],
68
- "metadata": {
69
- "kernelspec": {
70
- "display_name": "Python 3",
71
- "language": "python",
72
- "name": "python3"
73
- },
74
- "language_info": {
75
- "codemirror_mode": {
76
- "name": "ipython",
77
- "version": 3
78
- },
79
- "file_extension": ".py",
80
- "mimetype": "text/x-python",
81
- "name": "python",
82
- "nbconvert_exporter": "python",
83
- "pygments_lexer": "ipython3",
84
- "version": "3.9.5"
85
- }
86
- },
87
- "nbformat": 4,
88
- "nbformat_minor": 2
89
- }