Skip to content

Commit

Permalink
fix some typos
Browse files Browse the repository at this point in the history
  • Loading branch information
rbler1234 committed Dec 16, 2024
1 parent 2212495 commit 445c61b
Show file tree
Hide file tree
Showing 41 changed files with 2,817 additions and 2,197 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,12 @@ import mmscan
# (1) The dataset tool
import mmscan.MMScan as MMScan_dataset

# (2) The evaluator tool ('VG', 'QA', 'GPT')
import mmscan.{}_Evaluator as MMScan_{}_evaluator
# (2) The evaluator tool ('VisualGroundingEvaluator', 'QuestionAnsweringEvaluator', 'GPTEvaluator')
import mmscan.VisualGroundingEvaluator as MMScan_VG_evaluator

import mmscan.QuestionAnsweringEvaluator as MMScan_QA_evaluator

import mmscan.GPTEvaluator as MMScan_GPT_evaluator
```

### MMScan Dataset
Expand All @@ -124,7 +128,7 @@ Initialize the dataset for a specific task with:
```bash
my_dataset = MMScan_dataset(split='train', task="MMScan-QA", ratio=1.0)
# Access a specific sample
print(my_dataset[100])
print(my_dataset[index])
```

#### Data Access
Expand Down
Binary file modified assets/2024_NeurIPS_MMScan_Camera_Ready.pdf
Binary file not shown.
8 changes: 4 additions & 4 deletions data_preparation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Detailed steps are shown as follows.

3. Download Matterport3D data [HERE](https://github.com/niessner/Matterport). Link or move the folder to this level of directory.

4. Organize the file structure. You are recommanded to create a soft link to the raw data folder under `mmsan_data/embodiedscan-split/data`.
4. Organize the file structure. You are recommanded to create a soft link to the raw data folder under `mmscan_data/embodiedscan-split/data`.

```
mmsan_data/embodiedscan-split/data/
mmscan_data/embodiedscan-split/data/
├── scannet/
│ ├── scans
│ │ ├── <scene_id>
Expand All @@ -25,10 +25,10 @@ Detailed steps are shown as follows.
│ ├── ...
```

Additionally, create a `process_pcd` folder under `mmsan_data/embodiedscan-split` to store the results. Similarly, we recommend using a symbolic link, as the total file size might be a little large (approximately 21GB)
Additionally, create a `process_pcd` folder under `mmscan_data/embodiedscan-split` to store the results. Similarly, we recommend using a symbolic link, as the total file size might be a little large (approximately 21GB)

PS: If you have followed the embodiedscan tutorial to organize the data, you can skip these steps and link or copy the `data` folder to
`mmsan_data/embodiedscan-split`.
`mmscan_data/embodiedscan-split`.

After all the raw data is organized, the directory structure should be as below:

Expand Down
16 changes: 13 additions & 3 deletions data_preparation/process_all_scan.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
from argparse import ArgumentParser
from functools import wraps
from typing import Dict, Tuple

import mmengine
Expand All @@ -11,13 +12,22 @@
from utils.data_utils import read_annotation_pickle
from utils.mp3d_process import process_mp3d
from utils.pcd_utils import is_inside_box
from utils.proc_utils import mmengine_track_func
from utils.scannet_process import process_scannet
from utils.trscan_process import process_trscan
from utils.trscan_process import process_3rscan

es_anno = {}


def mmengine_track_func(func):

@wraps(func)
def wrapped_func(args):
result = func(*args)
return result

return wrapped_func


def create_scene_pcd(es_anno: dict,
pcd_result: Tuple[np.ndarray, np.ndarray, np.ndarray]) \
-> Tuple[np.ndarray, np.ndarray,
Expand Down Expand Up @@ -135,7 +145,7 @@ def process_one_scan(
return
pcd_info = create_scene_pcd(
es_anno['3rscan/' + scan_id],
process_trscan(scan_id, trscan_root, trscan_matrix),
process_3rscan(scan_id, trscan_root, trscan_matrix),
)

save_path = f'{save_root}/{scan_id}.pth'
Expand Down
2 changes: 1 addition & 1 deletion data_preparation/utils/mp3d_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def process_mp3d(new_scan_id: str, data_root: str,
"""Process matterport3d data.
Args:
scan_id (str): ID of the matterport3d scan.
new_scan_id (str): processed ID of the matterport3d scan.
data_root (str): Root directory of the matterport3d dataset.
axis_align_matrix_dict (dict): Dict of axis alignment matrices
for each scan.
Expand Down
2 changes: 2 additions & 0 deletions data_preparation/utils/pcd_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def is_inside_box(points: np.ndarray, center: np.ndarray, size: np.ndarray,
size(np.ndarray): size of the box, numpy array of shape (3, ).
rotation_mat(np.ndarray): rotation matrix of the box,
numpy array of shape (3, 3).
Returns:
np.ndarray: Boolean array of shape (n, ) indicating if each point
is inside the box.
Expand Down Expand Up @@ -121,6 +122,7 @@ def euler_to_matrix_np(euler):
Args:
euler (np.ndarray) : (..., 3)
Returns:
np.ndarray : (..., 3, 3)
"""
Expand Down
11 changes: 0 additions & 11 deletions data_preparation/utils/proc_utils.py

This file was deleted.

2 changes: 1 addition & 1 deletion data_preparation/utils/trscan_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pytorch3d.io import load_obj


def process_trscan(scan_id: str, data_root: str, axis_align: dict):
def process_3rscan(scan_id: str, data_root: str, axis_align: dict):
"""Process 3rscan data.
Args:
Expand Down
6 changes: 3 additions & 3 deletions mmscan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

print('MMScan module loaded')
try:
from mmscan.evaluator.vg_evaluation import VG_Evaluator
from mmscan.evaluator.vg_evaluation import VisualGroundingEvaluator
except:
pass
try:
from mmscan.evaluator.qa_evaluation import QA_Evaluator
from mmscan.evaluator.qa_evaluation import QuestionAnsweringEvaluator
except:
pass
try:
from mmscan.evaluator.gpt_evaluation import GPT_Evaluator
from mmscan.evaluator.gpt_evaluation import GPTEvaluator
except:
pass
5 changes: 4 additions & 1 deletion mmscan/evaluator/gpt_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from mmscan.utils.lang_utils import qa_metric_map, qa_prompt_define


class GPT_Evaluator:
class GPTEvaluator:
"""GPT metric, we set this for QA and Caption tasks.
Args:
Expand Down Expand Up @@ -55,6 +55,7 @@ def normal_query(self,
user_content_grounps (list[str]) :
The user content inputted into GPT.
max_tokens (int) : Max tokens. Defaults to 1000.
Returns:
dict : The json-format result.
"""
Expand Down Expand Up @@ -136,6 +137,7 @@ def qa_collection(self, num_threads: int, tmp_path: str) -> dict:
The number of threads used to evaluate the samples.
tmp_path (str) :
The path to store the tmp-stored json files.
Returns:
dict : The evaluation result.
"""
Expand Down Expand Up @@ -181,6 +183,7 @@ def load_and_eval(self,
num_threads (int) : The number of the threadings.
Defaults to 1.
tmp_path (str) : The temporay path to store the json files.
Returns:
dict : The evaluation result.
"""
Expand Down
3 changes: 2 additions & 1 deletion mmscan/evaluator/qa_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from mmscan.utils.lang_utils import special_token_filter


class QA_Evaluator:
class QuestionAnsweringEvaluator:
"""Tradition metrics for QA and Caption evaluation , consists the
implements of.
Expand Down Expand Up @@ -81,6 +81,7 @@ def update(self, batch_input: List[dict]) -> dict:
Args:
batch_input (list[dict]):
Batch of the raw original input.
Returns:
Dict: {"EM":EM metric for this batch,
"refined_EM":Refined EM metric for this batch}
Expand Down
2 changes: 1 addition & 1 deletion mmscan/evaluator/vg_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from mmscan.utils.box_utils import index_box, to_9dof_box


class VG_Evaluator:
class VisualGroundingEvaluator:
"""Evaluator for MMScan Visual Grounding benchmark. The evaluation metric
includes "AP","AP_C","AR","gTop-k".
Expand Down
10 changes: 10 additions & 0 deletions mmscan/mmscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def __getitem__(self, index_: int) -> dict:
Args:
index_ (int): The index.
Returns:
dict: The sample item corresponding to the index.
"""
Expand Down Expand Up @@ -281,6 +282,7 @@ def get_possess(self, table_name: str, scan_idx: str):
Args:
table_name (str): The ype of the expected data.
scan_idx (str): The scan id to get the data.
Returns:
The data corresponding to the table_name and scan_idx.
"""
Expand Down Expand Up @@ -330,6 +332,7 @@ def __filter_lang_anno__(self, samples: List[dict]) -> List[dict]:
Args:
samples (list[dict]): The samples.
Returns:
list[dict] : The filtered results.
"""
Expand All @@ -348,6 +351,7 @@ def __check_lang_anno__(self, sample: dict) -> bool:
Args:
sample (dict): The item from the samples.
Returns:
bool : Whether the item is valid or not.
"""
Expand Down Expand Up @@ -375,6 +379,7 @@ def __load_base_anno__(self, pkl_path: str) -> dict:
Args:
pkl_path (str): The path of the pkl.
Returns:
dict : The embodiedscan annotations of scans.
(with scan_idx as keys)
Expand All @@ -388,6 +393,7 @@ def __process_pcd_info__(self, scan_idx: str) -> dict:
Args:
scan_idx (str): ID of the scan.
Returns:
dict : The corresponding scan information.
"""
Expand Down Expand Up @@ -423,6 +429,7 @@ def __process_box_info__(self, scan_idx: str) -> dict:
Args:
scan_idx (str): ID of the scan.
Returns:
dict : The corresponding bounding boxes information.
"""
Expand All @@ -447,6 +454,7 @@ def __process_img_info__(self, scan_idx: str) -> List[dict]:
Args:
scan_idx (str): ID of the scan.
Returns:
list[dict] :The corresponding bounding boxes information
for each camera.
Expand Down Expand Up @@ -487,6 +495,7 @@ def down_9dof_to_6dof(
the point clouds
box_9DOF(np.ndarray / Tensor):
the 9DOF bounding box
Returns:
np.ndarray :
The transformed 6DOF bounding box.
Expand All @@ -501,6 +510,7 @@ def __downsample_annos__(self, annos: List[dict],
Args:
annos (list[dict]): The original annotations.
ratio (float): The ratio to downsample.
Returns:
list[dict] : The result.
"""
Expand Down
1 change: 1 addition & 0 deletions mmscan/utils/lang_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def clean_answer(data):
Args:
data (str): the raw sentence.
Returns:
data (str): the processed sentence.
"""
Expand Down
1 change: 1 addition & 0 deletions mmscan/utils/task_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def anno_token_flatten(samples: List[dict], keep_only_one: bool = True):
keep_only_one (bool):
Whether to keep only one positive token for each target.
Defaults to True.
Returns:
List[dict] : The token-flattened samples.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from terminaltables import AsciiTable
from tqdm import tqdm

from mmscan import VG_Evaluator
from mmscan import VisualGroundingEvaluator


def abbr(sub_class):
Expand Down Expand Up @@ -62,7 +62,7 @@ def __init__(self,
self.prefix = prefix
self.format_only = format_only
self.result_dir = result_dir
self.mmscan_eval = VG_Evaluator(True)
self.mmscan_eval = VisualGroundingEvaluator(True)

def to_mmscan_form(self, det_annos, gt_annos):
batch_input = []
Expand Down
4 changes: 2 additions & 2 deletions models/LEO/evaluator/GPT_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from argparse import ArgumentParser
from pathlib import Path

from mmscan import GPT_Evaluator
from mmscan import GPTEvaluator

if __name__ == '__main__':
parser = ArgumentParser()
Expand All @@ -15,7 +15,7 @@

leo_file_path = args.file

evaluator = GPT_Evaluator(eval_size =args.eval_size,\
evaluator = GPTEvaluator(eval_size =args.eval_size,\
API_key=args.api_key)

with open(leo_file_path, 'r') as f:
Expand Down
4 changes: 2 additions & 2 deletions models/LEO/evaluator/mmscan_eval.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from pathlib import Path

from mmscan import QA_Evaluator
from mmscan import QuestionAnsweringEvaluator

model_config = {'simcse': '', 'sbert': ''}

Expand All @@ -12,7 +12,7 @@
class MMScanEvaluator():

def __init__(self, cfg, task_name):
self.evaluator = QA_Evaluator(model_config)
self.evaluator = QuestionAnsweringEvaluator(model_config)
self.task_name = task_name
self.target_metric = 'refined_EM'
self.best_result = 0.0
Expand Down
2 changes: 1 addition & 1 deletion models/LL3DA/data/scannet/meta_data/render_option.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
"show_coordinate_frame" : false,
"version_major" : 1,
"version_minor" : 0
}
}
2 changes: 1 addition & 1 deletion models/LL3DA/data/scannet_category_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -606,4 +606,4 @@
"food bag": "others",
"clothes hangers": "others",
"starbucks cup": "others"
}
}
4 changes: 2 additions & 2 deletions models/LL3DA/eval_utils/evaluate_gpt.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from argparse import ArgumentParser

from mmscan import GPT_Evaluator
from mmscan import GPTEvaluator


def parse_form(results):
Expand All @@ -28,7 +28,7 @@ def parse_form(results):

ll3da_file_path = args.file

evaluator = GPT_Evaluator(eval_size =args.eval_size,\
evaluator = GPTEvaluator(eval_size =args.eval_size,\
API_key=args.api_key)

with open(ll3da_file_path, 'r') as f:
Expand Down
Loading

0 comments on commit 445c61b

Please sign in to comment.