Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two potential issues regarding preprocess_data.py. #12

Open
SophiaConner opened this issue Jan 18, 2025 · 0 comments
Open

Two potential issues regarding preprocess_data.py. #12

SophiaConner opened this issue Jan 18, 2025 · 0 comments

Comments

@SophiaConner
Copy link

SophiaConner commented Jan 18, 2025

First, I would like to express my gratitude to you and your organization for the continuous and outstanding contributions to the autonomous driving community.
While replicating the results of this project, I found two minor issues with the preprocess_data.py file. I have already resolved them personally, but for the convenience of new researchers, I would like to point them out here and hope that the author will consider making the necessary modifications.
The first potential issue:
The preprocess_data.py file does not define am, causing the system to fail to recognize the variable am. It is necessary to declare am = ArgoverseMap() in the global variable section of the code, for example:

import zlib
import pickle
from argoverse.map_representation.map_api import ArgoverseMap
am= ArgoverseMap()
codeEnd

The second potential issue:
The calc_ex_list function should be placed above the create_dataset function, not inside it. Otherwise, it will cause an error (AttributeError: Can't pickle local object 'create_dataset..calc_ex_list').

def calc_ex_list(queue, queue_res, args):
res = []
while True:
file = queue.get()
if file is None:
break
if file.endswith("csv"):
with open(file, "r", encoding='utf-8') as fin:
lines = fin.readlines()[1:]
instance = argoverse_get_instance(
args, lines, file)
if instance is not None:
data_compress = zlib.compress(
pickle.dumps(instance))
res.append(data_compress)
queue_res.put(data_compress)
else:
queue_res.put(None)

def create_dataset(args):
global am
am = ArgoverseMap()
files = []
for each_dir in args.data_dir:
root, dirs, cur_files = os.walk(each_dir).next()
files.extend([os.path.join(each_dir, file) for file in cur_files if
file.endswith("csv") and not file.startswith('.')])
print(files[:5], files[-5:])

pbar = tqdm(total=len(files))
queue = multiprocessing.Queue(args.core_num)
queue_res = multiprocessing.Queue()
processes = [Process(target=calc_ex_list, args=(
    queue, queue_res, args,)) for _ in range(args.core_num)]
for each in processes:
    each.start()

for file in files:
    assert file is not None
    queue.put(file)
    pbar.update(1)

while not queue.empty():
    pass

pbar.close()
ex_list = []

pbar = tqdm(total=len(files))
for i in range(len(files)):
    t = queue_res.get()
    if t is not None:
        ex_list.append(t)
    pbar.update(1)
pbar.close()

for i in range(args.core_num):
    queue.put(None)
for each in processes:
    each.join()

if args.test:
    ex_file_name = "test.ex_list"
elif args.validation:
    ex_file_name = "eval.ex_list"
else:
    ex_file_name = "ex_list"
pickle_file = open(os.path.join(
    args.output_dir, ex_file_name), 'wb')
pickle.dump(ex_list, pickle_file)
pickle_file.close()
assert len(ex_list) > 0
print("valid data size is", len(ex_list))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant