terrakio-core 0.4.0__tar.gz → 0.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of terrakio-core might be problematic. Click here for more details.

Files changed (26) hide show
  1. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/PKG-INFO +1 -1
  2. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/pyproject.toml +1 -1
  3. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core/__init__.py +1 -1
  4. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core/endpoints/model_management.py +43 -7
  5. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core.egg-info/PKG-INFO +1 -1
  6. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/README.md +0 -0
  7. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/setup.cfg +0 -0
  8. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core/async_client.py +0 -0
  9. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core/client.py +0 -0
  10. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core/config.py +0 -0
  11. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core/convenience_functions/convenience_functions.py +0 -0
  12. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core/endpoints/auth.py +0 -0
  13. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core/endpoints/dataset_management.py +0 -0
  14. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core/endpoints/group_management.py +0 -0
  15. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core/endpoints/mass_stats.py +0 -0
  16. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core/endpoints/space_management.py +0 -0
  17. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core/endpoints/user_management.py +0 -0
  18. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core/exceptions.py +0 -0
  19. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core/helper/bounded_taskgroup.py +0 -0
  20. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core/helper/decorators.py +0 -0
  21. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core/helper/tiles.py +0 -0
  22. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core/sync_client.py +0 -0
  23. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core.egg-info/SOURCES.txt +0 -0
  24. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core.egg-info/dependency_links.txt +0 -0
  25. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core.egg-info/requires.txt +0 -0
  26. {terrakio_core-0.4.0 → terrakio_core-0.4.2}/terrakio_core.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: terrakio-core
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: Core components for Terrakio API clients
5
5
  Author-email: Yupeng Chao <yupeng@haizea.com.au>
6
6
  Project-URL: Homepage, https://github.com/HaizeaAnalytics/terrakio-python-api
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "terrakio-core"
7
- version = "0.4.0"
7
+ version = "0.4.2"
8
8
  authors = [
9
9
  {name = "Yupeng Chao", email = "yupeng@haizea.com.au"},
10
10
  ]
@@ -5,7 +5,7 @@ Terrakio Core
5
5
  Core components for Terrakio API clients.
6
6
  """
7
7
 
8
- __version__ = "0.4.0"
8
+ __version__ = "0.4.2"
9
9
 
10
10
  from .async_client import AsyncClient
11
11
  from .sync_client import SyncClient as Client
@@ -903,19 +903,39 @@ class ModelManagement:
903
903
  " output = model.run(None, {\"float_input\": input_data})[0]",
904
904
  " logging.info(f\"Model output shape: {output.shape}\")",
905
905
  " ",
906
- " # Process output back to xarray format",
907
- " # Assuming output is (1, height, width) or (1, 1, height, width)",
908
- " if output.ndim == 4 and output.shape[1] == 1:",
909
- " # Remove channel dimension if it's 1",
910
- " output_2d = output[0, 0]",
906
+ " # UPDATED: Handle multi-class CNN output properly",
907
+ " if output.ndim == 4:",
908
+ " if output.shape[1] == 1:",
909
+ " # Single class output (regression or binary classification)",
910
+ " output_2d = output[0, 0]",
911
+ " logging.info(\"Single channel output detected\")",
912
+ " else:",
913
+ " # Multi-class output - convert logits/probabilities to class predictions",
914
+ " output_classes = np.argmax(output, axis=1) # Shape: (1, height, width)",
915
+ " output_2d = output_classes[0] # Shape: (height, width)",
916
+ " ",
917
+ " # Apply class merging: merge class 6 into class 3",
918
+ " output_2d = np.where(output_2d == 6, 3, output_2d)",
919
+ " ",
920
+ " logging.info(f\"Multi-class output processed. Original classes: {output.shape[1]}\")",
921
+ " logging.info(f\"Unique classes in output: {np.unique(output_2d)}\")",
922
+ " logging.info(f\"Class distribution: {np.bincount(output_2d.flatten())}\")",
911
923
  " elif output.ndim == 3:",
912
924
  " # Remove batch dimension",
913
925
  " output_2d = output[0]",
926
+ " logging.info(\"3D output detected, removed batch dimension\")",
914
927
  " else:",
915
928
  " # Handle other cases",
916
929
  " output_2d = np.squeeze(output)",
917
930
  " if output_2d.ndim != 2:",
931
+ " logging.error(f\"Cannot process output shape: {output.shape}\")",
932
+ " logging.error(f\"After squeeze: {output_2d.shape}\")",
918
933
  " raise ValueError(f\"Unexpected output shape after processing: {output_2d.shape}\")",
934
+ " logging.info(\"Applied squeeze to output\")",
935
+ " ",
936
+ " # Ensure output is 2D",
937
+ " if output_2d.ndim != 2:",
938
+ " raise ValueError(f\"Final output must be 2D, got shape: {output_2d.shape}\")",
919
939
  " ",
920
940
  " # Determine output timestamp (use the latest timestamp)",
921
941
  " output_timestamp = time_coords[-1]",
@@ -923,18 +943,34 @@ class ModelManagement:
923
943
  " # Get spatial coordinates from reference array",
924
944
  " spatial_coords = {dim: reference_array.coords[dim] for dim in spatial_dims}",
925
945
  " ",
926
- " # Create output DataArray",
946
+ " # Create output DataArray with appropriate data type",
947
+ " # Use int32 for classification, float32 for regression",
948
+ " is_multiclass = output.ndim == 4 and output.shape[1] > 1",
949
+ " if is_multiclass:",
950
+ " # Multi-class classification - use integer type",
951
+ " output_dtype = np.int32",
952
+ " output_type = 'classification'",
953
+ " else:",
954
+ " # Single output - use float type",
955
+ " output_dtype = np.float32",
956
+ " output_type = 'regression'",
957
+ " ",
927
958
  " result = xr.DataArray(",
928
- " data=np.expand_dims(output_2d.astype(np.float32), axis=0),",
959
+ " data=np.expand_dims(output_2d.astype(output_dtype), axis=0),",
929
960
  " dims=['time'] + spatial_dims,",
930
961
  " coords={",
931
962
  " 'time': [output_timestamp.values],",
932
963
  " spatial_dims[0]: spatial_coords[spatial_dims[0]].values,",
933
964
  " spatial_dims[1]: spatial_coords[spatial_dims[1]].values",
965
+ " },",
966
+ " attrs={",
967
+ " 'description': 'CNN model prediction',",
934
968
  " }",
935
969
  " )",
936
970
  " ",
937
971
  " logging.info(f\"Final result shape: {result.shape}\")",
972
+ " logging.info(f\"Final result data type: {result.dtype}\")",
973
+ " logging.info(f\"Final result value range: {result.values.min()} to {result.values.max()}\")",
938
974
  ])
939
975
 
940
976
  # Add postprocessing call if postprocessing exists
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: terrakio-core
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: Core components for Terrakio API clients
5
5
  Author-email: Yupeng Chao <yupeng@haizea.com.au>
6
6
  Project-URL: Homepage, https://github.com/HaizeaAnalytics/terrakio-python-api
File without changes
File without changes