JonasSchult / Mask3D

Mask3D predicts accurate 3D semantic instances achieving state-of-the-art on ScanNet, ScanNet200, S3DIS and STPLS3D.
MIT License
525 stars 103 forks source link

base_path & target_path when testing STPLS3D #143

Closed YEOMJINSEOP closed 10 months ago

YEOMJINSEOP commented 10 months ago

Thank you for sharing great works!

While i was testing mask3D using STPLS3D after Training, I faced error "python: can't open file '~ / Mask3D/merge_exports.py': [Errno 2] No such file or directory " So, i moved 'merge_exports.py' from '~ / Mask3D/scripts/stpls3d/merge_exports.py' to '~/Mask3D/merge_exports.py'

However, after this error solved, i faced error "FileNotFoundError: [Errno 2] No such file or directory: 'INSERT_WORKING_DIRECTORY/benchmark_02/pred_mask'".

The problem is that I can't find directory which has "benchmark_02/pred_mask". Could you tell me how should i set base_path and target_path in this "merge_exports.py"? and what is this file for?

I attached my "~Mask3D/scripts/stpls3d/stpls3d_benchmark.sh" and "~Mask3D/merge_exports.py" below. Thank you!

<~Mask3D/merge_exports.py>

import os
import shutil
from glob import glob
from tqdm import tqdm

#⭐
base_path = "INSERT_WORKING_DIRECTORY"
vs03 = f"{base_path}/benchmark_03"
vs02 = f"{base_path}/benchmark_02"

#⭐
target_path = "INSERT_TARGET_DIRECTORY"

print("COPY MASKS FILES 1/2 ...")
shutil.copytree(f"{vs02}/pred_mask", f"{target_path}/pred_mask_02")
print("COPY MASKS FILES 2/2 ...")
shutil.copytree(f"{vs03}/pred_mask", f"{target_path}/pred_mask_03")

for scene03 in tqdm(glob(f"{vs03}/*.txt")):
    instances = []
    with open(scene03, "r") as file03:
        while line := file03.readline().rstrip():
            mask_path, class_id, score = line.split(" ")

if int(class_id) in [1, 3, 4, 7, 8, 11, 12, 13]:
                instances.append(
                    f'{mask_path.replace("pred_mask", "pred_mask_03")} {class_id} {score}'
                )
                print(instances[-1])
            else:
                print(
                    f'DELETE {target_path}/{mask_path.replace("pred_mask", "pred_mask_03")}'
                )
                os.remove(
                    f'{target_path}/{mask_path.replace("pred_mask", "pred_mask_03")}'
                )

with open(f'{vs02}/{scene03.split("/")[-1]}', "r") as file02:
            while line := file02.readline().rstrip():
                mask_path, class_id, score = line.split(" ")

if int(class_id) not in [1, 3, 4, 7, 8, 11, 12, 13]:
                    instances.append(
                        f'{mask_path.replace("pred_mask", "pred_mask_02")} {class_id} {score}'
                    )
                    print(instances[-1])
                else:
                    print(
                        f'DELETE {target_path}/{mask_path.replace("pred_mask", "pred_mask_02")}'
                    )
os.remove(
                        f'{target_path}/{mask_path.replace("pred_mask", "pred_mask_02")}'
                    )

with open(f'{target_path}/{scene03.split("/")[-1]}', "w") as fout:
        for line in instances:
            fout.write(f"{line}\n")
FatemehTarashi commented 9 months ago

@YEOMJINSEOP can you please tell me how you solved this? I have exactly the same problem.