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

5 band model won't run due to vstack error #158

Closed
2320sharon opened this issue Jul 6, 2023 · 3 comments
Closed

5 band model won't run due to vstack error #158

2320sharon opened this issue Jul 6, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@2320sharon
Copy link
Collaborator

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~\anaconda3\envs\coastseg\lib\site-packages\ipywidgets\widgets\widget_output.py:103, in Output.capture.<locals>.capture_decorator.<locals>.inner(*args, **kwargs)
    101     self.clear_output(*clear_args, **clear_kwargs)
    102 with self:
--> 103     return func(*args, **kwargs)

File C:\development\doodleverse\coastseg\CoastSeg\src\coastseg\models_UI.py:550, in UI_Models.run_model_button_clicked(self, button)
    548 if self.otsu_radio.value == "Disabled":
    549     self.model_dict["tta"] = False
--> 550 zoo_model_instance.run_model(
    551     img_type,
    552     self.model_dict["implementation"],
    553     session_name,
    554     self.model_dict["sample_direc"],
    555     model_name=self.model_dict["model_type"],
    556     use_GPU="0",
    557     use_otsu=self.model_dict["otsu"],
    558     use_tta=self.model_dict["tta"],
    559     percent_no_data=percent_no_data,
    560 )

File C:\development\doodleverse\coastseg\CoastSeg\src\coastseg\zoo_model.py:945, in Zoo_Model.run_model(self, img_type, model_implementation, session_name, src_directory, model_name, use_GPU, use_otsu, use_tta, percent_no_data)
    943 roi_directory = common.find_parent_directory(src_directory, "ID_", "data")
    944 print(f"Preprocessing the data at {roi_directory}")
--> 945 model_dict = self.preprocess_data(roi_directory, model_dict, img_type)
    946 logger.info(f"model_dict: {model_dict}")
    948 self.compute_segmentation(model_dict, percent_no_data)

File C:\development\doodleverse\coastseg\CoastSeg\src\coastseg\zoo_model.py:693, in Zoo_Model.preprocess_data(self, src_directory, model_dict, img_type)
    691 RGB_path = common.find_directory_recurively(src_directory, name="RGB")
    692 # convert RGB to MNDWI, NDWI,or 5 band
--> 693 model_dict["sample_direc"] = get_imagery_directory(img_type, RGB_path)
    694 logger.info(f"model_dict: {model_dict}")
    695 return model_dict

File C:\development\doodleverse\coastseg\CoastSeg\src\coastseg\zoo_model.py:271, in get_imagery_directory(img_type, RGB_path)
    269 elif img_type == "RGB+MNDWI+NDWI":
    270     NIR_path = os.path.join(output_path, "NIR")
--> 271     NDWI_path = RGB_to_infrared(RGB_path, NIR_path, output_path, "NDWI")
    272     SWIR_path = os.path.join(output_path, "SWIR")
    273     MNDWI_path = RGB_to_infrared(RGB_path, SWIR_path, output_path, "MNDWI")

File C:\development\doodleverse\coastseg\CoastSeg\src\coastseg\zoo_model.py:386, in RGB_to_infrared(RGB_path, infrared_path, output_path, output_type)
    382     raise Exception(
    383         f"Invalid output_type given must be MNDWI or NDWI. Cannot be {output_type}"
    384     )
    385 # matrix:bands(RGB) x number of samples(NIR)
--> 386 files = get_files(RGB_path, infrared_path)
    387 # output_path: directory to store MNDWI or NDWI outputs
    388 output_path = os.path.join(output_path, output_type.upper())

File C:\development\doodleverse\coastseg\CoastSeg\src\coastseg\zoo_model.py:356, in get_files(RGB_dir_path, img_dir_path)
    354     files.append(f)
    355 # creates matrix:  bands(RGB) x number of samples
--> 356 files = np.vstack(files).T
    357 return files

File <__array_function__ internals>:180, in vstack(*args, **kwargs)

File ~\anaconda3\envs\coastseg\lib\site-packages\numpy\core\shape_base.py:282, in vstack(tup)
    280 if not isinstance(arrs, list):
    281     arrs = [arrs]
--> 282 return _nx.concatenate(arrs, 0)

File <__array_function__ internals>:180, in concatenate(*args, **kwargs)

ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 47 and the array at index 1 has size 71
@2320sharon 2320sharon added the bug Something isn't working label Jul 6, 2023
@2320sharon 2320sharon self-assigned this Jul 6, 2023
@2320sharon
Copy link
Collaborator Author

I figured out the cause of this error and related errors. When users remove files from the RGB directory the files in the NIR and SWIR directories no longer match the number of files in the RGB directory causing errors when you try to stack the two lists together because they aren't the same size

@2320sharon
Copy link
Collaborator Author

The fix is in 768251d
I accidentally referenced the wrong issue

@2320sharon
Copy link
Collaborator Author

2320sharon commented Jul 7, 2023

  • Add to prerelease for 0.0.72.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant