From e00f6a10ecff5ca7edf5c11d44ca486e6a759146 Mon Sep 17 00:00:00 2001 From: jiaruiyu99 Date: Wed, 30 Oct 2024 13:39:40 +0100 Subject: [PATCH] Change the path to save temperature bound json file --- thermo_scenes/docs/Collect_new_dataset.md | 4 +-- thermo_scenes/scripts/preprocess_thermal.py | 29 ++++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/thermo_scenes/docs/Collect_new_dataset.md b/thermo_scenes/docs/Collect_new_dataset.md index 1593261..e4354c5 100644 --- a/thermo_scenes/docs/Collect_new_dataset.md +++ b/thermo_scenes/docs/Collect_new_dataset.md @@ -47,10 +47,10 @@ sudo pip install numpy matplotlib pillow ### Extact raw data To create the CSV files, rgb images, and the greyscale raw temperature images, run -the following command, with `` the path to the MSX images, and ``, ``, and `` the paths where the temperature and rgb images, and csv files extracted will be saved. +the following command, with `` the path to the MSX images, and `` the path where the temperature and rgb images, and csv files extracted will be saved. ```bash -thermoscenes_preprocess_thermal.py --path-to-thermal-images --path-to-thermal-images-curated --path-to-rgb --path-to-csv-files +thermoscenes_preprocess_thermal.py --path-to-thermal-images --path-to-output-folder ``` > If your MSX images are in more than one folder, do it for all folders, and make sure that the temperature are rescaled to the same range in the next step. diff --git a/thermo_scenes/scripts/preprocess_thermal.py b/thermo_scenes/scripts/preprocess_thermal.py index e3c100c..85573c5 100644 --- a/thermo_scenes/scripts/preprocess_thermal.py +++ b/thermo_scenes/scripts/preprocess_thermal.py @@ -8,36 +8,39 @@ @dataclass class Paths: - path_to_thermal_images: str + path_to_thermal_images: str = "/home/jiyu/LES-dorm2/msx_train" """Path to the thermal data extracted from Flir One App.""" - path_to_thermal_images_curated: str - """Path to the output thermal images created using raw thermal data.""" - path_to_rgb: str - """Path to the output rgb images""" - path_to_csv_files: str - """Path to the output csv files of temperature values""" - path_to_txt: str = "temperature_bounds.json" - """Path to the txt file with temperature bounds for the dataset""" + path_to_output_folder: str = "/home/jiyu/LES-dorm2/test" + """Path to the output folder""" def main() -> None: paths = tyro.cli(Paths) + output_json_path = Path(paths.path_to_output_folder, "temperature_bounds.json") + output_rgb_folder = Path(paths.path_to_output_folder, "rgb") + output_thermal_folder = Path(paths.path_to_output_folder, "thermal") + output_csv_folder = Path(paths.path_to_output_folder, "csv") + + output_rgb_folder.mkdir(parents=True, exist_ok=True) + output_thermal_folder.mkdir(parents=True, exist_ok=True) + output_csv_folder.mkdir(parents=True, exist_ok=True) + list_thermal = [] list_filenames = [] flir = CustomFlir() for img_name in Path(paths.path_to_thermal_images).iterdir(): flir.process_image(Path(paths.path_to_thermal_images, img_name.name)) flir.export_thermal_to_csv( - Path(paths.path_to_csv_files, str(img_name.name).split(".")[0] + ".csv") + Path(output_csv_folder, str(img_name.name).split(".")[0] + ".csv") ) - flir.save_rgb_images(Path(paths.path_to_rgb)) + flir.save_rgb_images(output_rgb_folder) list_thermal.append(flir.get_thermal_np()) list_filenames.append(str(img_name.name)) flir.save_normalised_thermal_images( - paths.path_to_thermal_images_curated, paths.path_to_csv_files + str(output_thermal_folder), str(output_csv_folder) ) - flir.save_temperature_bounds(paths.path_to_txt) + flir.save_temperature_bounds(str(output_json_path)) if __name__ == "__main__":