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

[BUG] BBOX parameter not working properly. #25

Closed
mpelchat04 opened this issue Oct 21, 2024 · 1 comment
Closed

[BUG] BBOX parameter not working properly. #25

mpelchat04 opened this issue Oct 21, 2024 · 1 comment

Comments

@mpelchat04
Copy link
Collaborator

2 things limit the use of the bbox argument for inference.

1: Data type error converting the bbox to col/row index.

Traceback (most recent call last):
  File "d:\Travail\AIAAS\geo_inf_ella.py", line 22, in <module>
    geo_inference(inference_input=r"D:\Travail\AIAAS\0.tif",
  File "D:\conda_envs\geo_inference300\Lib\site-packages\torch\utils\_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "D:\conda_envs\geo_inference300\Lib\site-packages\geo_inference\geo_inference.py", line 158, in __call__
    asyncio.run(run_async())
  File "D:\conda_envs\geo_inference300\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "D:\conda_envs\geo_inference300\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\conda_envs\geo_inference300\Lib\asyncio\base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "D:\conda_envs\geo_inference300\Lib\site-packages\geo_inference\geo_inference.py", line 144, in run_async
    self.mask_layer_name = await self.async_run_inference(
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\conda_envs\geo_inference300\Lib\site-packages\geo_inference\geo_inference.py", line 371, in async_run_inference
    raise e
  File "D:\conda_envs\geo_inference300\Lib\site-packages\geo_inference\geo_inference.py", line 298, in async_run_inference
    aoi_dask_array = aoi_dask_array[
                     ^^^^^^^^^^^^^^^
  File "D:\conda_envs\geo_inference300\Lib\site-packages\xarray\core\dataarray.py", line 899, in __getitem__
    return self.isel(indexers=self._item_key_to_dict(key))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\conda_envs\geo_inference300\Lib\site-packages\xarray\core\dataarray.py", line 1535, in isel
    variable = self._variable.isel(indexers, missing_dims=missing_dims)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\conda_envs\geo_inference300\Lib\site-packages\xarray\core\variable.py", line 1038, in isel
    return self[key]
           ~~~~^^^^^
  File "D:\conda_envs\geo_inference300\Lib\site-packages\xarray\core\variable.py", line 802, in __getitem__
    dims, indexer, new_order = self._broadcast_indexes(key)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\conda_envs\geo_inference300\Lib\site-packages\xarray\core\variable.py", line 638, in _broadcast_indexes
    return self._broadcast_indexes_basic(key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\conda_envs\geo_inference300\Lib\site-packages\xarray\core\variable.py", line 668, in _broadcast_indexes_basic
    return dims, BasicIndexer(key), None
                 ^^^^^^^^^^^^^^^^^
  File "D:\conda_envs\geo_inference300\Lib\site-packages\xarray\core\indexing.py", line 397, in __init__
    k = as_integer_slice(k)
        ^^^^^^^^^^^^^^^^^^^
  File "D:\conda_envs\geo_inference300\Lib\site-packages\xarray\core\indexing.py", line 351, in as_integer_slice
    stop = as_integer_or_none(value.stop)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\conda_envs\geo_inference300\Lib\site-packages\xarray\core\indexing.py", line 346, in as_integer_or_none
    return None if value is None else operator.index(value)
                                      ^^^^^^^^^^^^^^^^^^^^^
TypeError: 'float' object cannot be interpreted as an integer

In geo_inference.py, converting the col/row offsets to int fixes this issue.
image

2 : The writen array is not properly placed.

The xy offset is not used to write the mask, when using the bbox parameter. The mask is systematically located in the upper-left corner of the original image.
image

@mpelchat04
Copy link
Collaborator Author

Closed by #28

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