Ex 5 - Datacube for ML¶
This notebook briefly describes how to use the Datacube
class for ML projects.
We will use small and non-representive datasets for the example. The aim is for you to be able to run the code and understand the core concept of integrating the datacube into your ML project.
In this example we will cover two main ML applications using the Torch framework:
Segmentation: performs pixel-wise labeling with a set of object categories (for example, people, trees, sky, cars) for all image pixels.
Object classification: refers to a collection of related tasks for identifying objects in digital photographs.
This example is dependent on installing pytorch
, xbatcher
.
NOTE: In order to execute this notebook successfully, one might have to instal extra dependencies for ML packages. Please install ml_requirements
as mentioned in setup.py
using pip install -e .[ml]
# Or uncomment the below line to install them.
#! pip install -e ../../.[ml]
from pathlib import Path
import os
import icecube
from icecube.bin.datacube import Datacube
from icecube.bin.generate_cube import IceyeProcessGenerateCube
import xbatcher
import torch
from torch.utils.data import Dataset
from torchvision import datasets
import xarray
import numpy as np
from torch.utils.data import DataLoader
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.pyplot as plt
import torch.nn as nn
from torch.autograd import Variable
Segmentation Example¶
# Read the datacube inputs
resource_dir = os.path.join(str(Path(icecube.__file__).parent.parent), "tests/resources")
grd_raster_dir = os.path.join(resource_dir, "grd_stack")
cube_config_fpath = os.path.join(resource_dir, "json_config/config_use_case5.json")
# This is file is created when you run the tests - please run `inv test` first.
masks_labels_fpath = os.path.join(resource_dir, "labels/dummy_mask_labels.json")
#[
# {
# "product_file": "ICEYE_GRD_SLED_54549_20210427T215124_hollow_10x10pixels_fake_0.tif",
# "labels": {
# "segmentation": "/home/adupeyrat/Documents/code/icecube/tests/resources/masks/ICEYE_GRD_SLED_54549_20210427T215124_hollow_10x10pixels_fake_0.png"
# }
# },
dc = IceyeProcessGenerateCube.create_cube(grd_raster_dir, cube_config_fpath, masks_labels_fpath)
09/10/2021 07:59:39 PM - sar_datacube_metadata.py - [INFO] - Building the metadata from the folder /mnt/xor/ICEYE_PACKAGES/icecube/tests/resources/grd_stack using GRD processing rasters for cubes: 100%|██████████| 6/6 [00:00<00:00, 298.93it/s] 09/10/2021 07:59:39 PM - common_utils.py - [INFO] - create running time is 0.0431 seconds 09/10/2021 07:59:39 PM - sar_datacube_metadata.py - [INFO] - Building the metadata from the folder /mnt/xor/ICEYE_PACKAGES/icecube/tests/resources/grd_stack using GRD /home/iali/anaconda3/envs/icecube_env_test/lib/python3.8/site-packages/rasterio/__init__.py:220: NotGeoreferencedWarning: Dataset has no geotransform, gcps, or rpcs. The identity matrix be returned. s = DatasetReader(path, driver=driver, sharing=sharing, **kwargs) processing rasters for labels cube: 100%|██████████| 6/6 [00:00<00:00, 957.68it/s] 09/10/2021 07:59:39 PM - common_utils.py - [INFO] - create running time is 0.0285 seconds
dc.xrdataset
<xarray.Dataset> Dimensions: (Azimuth: 10, Range: 10, Band: 6) Coordinates: * Azimuth (Azimuth) int64 0 1 2 3 4 5 6 7 8 9 * Range (Range) int64 0 1 2 3 4 5 6 7 8 9 * Band (Band) datetime64[ns] 2021-04-25 2021-04-26 ... 2021-04-30 Data variables: Intensity (Band, Azimuth, Range) uint16 dask.array<chunksize=(1, 10, 10), meta=np.ndarray> Labels (Band, Azimuth, Range) uint8 dask.array<chunksize=(1, 10, 10), meta=np.ndarray>
- Azimuth: 10
- Range: 10
- Band: 6
- Azimuth(Azimuth)int640 1 2 3 4 5 6 7 8 9
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
- Range(Range)int640 1 2 3 4 5 6 7 8 9
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
- Band(Band)datetime64[ns]2021-04-25 ... 2021-04-30
array(['2021-04-25T00:00:00.000000000', '2021-04-26T00:00:00.000000000', '2021-04-27T00:00:00.000000000', '2021-04-28T00:00:00.000000000', '2021-04-29T00:00:00.000000000', '2021-04-30T00:00:00.000000000'], dtype='datetime64[ns]')
- Intensity(Band, Azimuth, Range)uint16dask.array<chunksize=(1, 10, 10), meta=np.ndarray>
- mean_earth_radius :
- ['None', 'None', '6370576.1554293325', '6370576.1554293325', 'None', 'None']
- window_function_azimuth :
- ['None', 'None', 'TAYLOR_20_4', 'TAYLOR_20_4', 'None', 'None']
- number_of_azimuth_samples :
- ['None', 'None', '10', '10', 'None', 'None']
- sample_precision :
- ['None', 'None', 'uint16', 'uint16', 'None', 'None']
- incidence_angle_poly_order :
- ['None', 'None', '4', '4', 'None', 'None']
- tropo_range_delay :
- ['None', 'None', '2.8238412754811586', '2.8238412754811586', 'None', 'None']
- number_of_dc_estimations :
- ['None', 'None', '10', '10', 'None', 'None']
- acquisition_mode :
- ['None', 'None', 'spotlight', 'spotlight', 'None', 'None']
- azimuth_spacing :
- ['None', 'None', '0.5', '0.5', 'None', 'None']
- heading :
- ['None', 'None', '349.91295192092355', '349.91295192092355', 'None', 'None']
- processing_time :
- ['None', 'None', '2021-04-28T04:58:23', '2021-04-28T04:58:23', 'None', 'None']
- mean_orbit_altitude :
- ['None', 'None', '536675.3876030303', '536675.3876030303', 'None', 'None']
- azimuth_look_bandwidth :
- ['None', 'None', '9478.957370916767', '9478.957370916767', 'None', 'None']
- grsr_zero_doppler_time :
- ['None', 'None', '2021-04-27T21:51:27.475116', '2021-04-27T21:51:27.475116', 'None', 'None']
- azimuth_look_overlap :
- ['None', 'None', '1042.4495680720643', '1042.4495680720643', 'None', 'None']
- carrier_frequency :
- ['None', 'None', '9650000000.0', '9650000000.0', 'None', 'None']
- product_file :
- ['None', 'None', 'ICEYE_GRD_54549_20210427T215124_hollow_10x10pixels_fake_1.tif', 'ICEYE_GRD_54549_20210427T215124_hollow_10x10pixels_fake_0.tif', 'None', 'None']
- number_of_state_vectors :
- ['None', 'None', '81', '81', 'None', 'None']
- applied_processing :
- ['None', 'None', "{'library_version': '0.1.0', 'processing': {}}", "{'library_version': '0.1.0', 'processing': {}}", 'None', 'None']
- range_spread_comp_flag :
- ['None', 'None', '1', '1', 'None', 'None']
- incidence_angle_zero_doppler_time :
- ['None', 'None', '2021-04-27T21:51:27.475116', '2021-04-27T21:51:27.475116', 'None', 'None']
- posZ :
- ['None', 'None', '[4109487.20309768 4110089.38320021 4110691.51494008 4111293.59543885\n 4111895.62756019 4112497.60842612 4113099.5394648 4113701.42210389\n 4114303.25346613 4114905.03641401 4115506.76807074 4116108.44986388\n 4116710.0832205 4117311.66526454 4117913.19885731 4118514.68112321\n 4119116.11348921 4119717.4973818 4120318.82992609 4120920.1139822\n 4121521.34667574 4122122.52943307 4122723.66368008 4123324.7465431\n 4123925.78088107 4124526.76382077 4125127.69678798 4125728.58120801\n 4126329.41420836 4126930.19864679 4127530.93165127 4128131.61464698\n 4128732.24905865 4129332.83201498 4129933.36637252 4130533.84926045\n 4131134.28210339 4131734.66632543 4132334.99905648 4132935.2831519\n 4133535.51574207 4134135.69825099 4134735.83210218 4135335.91442675\n 4135935.94807886 4136535.9301901 4137135.86218387 4137735.74548311\n 4138335.5772201 4138935.36024782 4139535.09169906 4140134.77299661\n 4140734.40556282 4141333.98653118 4141933.51875348 4142532.9993637\n 4143132.42978405 4143731.81143628 4144331.14145507 4144930.42269102\n 4145529.6522793 4146128.83164154 4146727.96219887 4147327.0410872\n 4147926.07115592 4148525.04954141 4149123.9776647 4149722.85694634\n 4150321.68452341 4150920.46324413 4151519.19024607 4152117.86694965\n 4152716.49477483 4153315.07085991 4153913.5980519 4154512.07348958\n 4155110.49859279 4155708.87478087 4156307.19919332 4156905.47467597\n 4157503.69836878]', '[4109487.20309768 4110089.38320021 4110691.51494008 4111293.59543885\n 4111895.62756019 4112497.60842612 4113099.5394648 4113701.42210389\n 4114303.25346613 4114905.03641401 4115506.76807074 4116108.44986388\n 4116710.0832205 4117311.66526454 4117913.19885731 4118514.68112321\n 4119116.11348921 4119717.4973818 4120318.82992609 4120920.1139822\n 4121521.34667574 4122122.52943307 4122723.66368008 4123324.7465431\n 4123925.78088107 4124526.76382077 4125127.69678798 4125728.58120801\n 4126329.41420836 4126930.19864679 4127530.93165127 4128131.61464698\n 4128732.24905865 4129332.83201498 4129933.36637252 4130533.84926045\n 4131134.28210339 4131734.66632543 4132334.99905648 4132935.2831519\n 4133535.51574207 4134135.69825099 4134735.83210218 4135335.91442675\n 4135935.94807886 4136535.9301901 4137135.86218387 4137735.74548311\n 4138335.5772201 4138935.36024782 4139535.09169906 4140134.77299661\n 4140734.40556282 4141333.98653118 4141933.51875348 4142532.9993637\n 4143132.42978405 4143731.81143628 4144331.14145507 4144930.42269102\n 4145529.6522793 4146128.83164154 4146727.96219887 4147327.0410872\n 4147926.07115592 4148525.04954141 4149123.9776647 4149722.85694634\n 4150321.68452341 4150920.46324413 4151519.19024607 4152117.86694965\n 4152716.49477483 4153315.07085991 4153913.5980519 4154512.07348958\n 4155110.49859279 4155708.87478087 4156307.19919332 4156905.47467597\n 4157503.69836878]', 'None', 'None']
- range_look_overlap :
- ['None', 'None', '0.0', '0.0', 'None', 'None']
- range_look_bandwidth :
- ['None', 'None', '299486104.61513484', '299486104.61513484', 'None', 'None']
- product_type :
- ['None', 'None', 'SpotlightExtendedDwell', 'SpotlightExtendedDwell', 'None', 'None']
- number_of_range_samples :
- ['None', 'None', '10', '10', 'None', 'None']
- acquisition_end_utc :
- ['None', 'None', '2021-04-27T21:51:30.025535', '2021-04-28T21:51:30.025535', 'None', 'None']
- grsr_ground_range_origin :
- ['None', 'None', '0.0', '0.0', 'None', 'None']
- coord_first_far :
- ['None', 'None', '[ 1.17480000e+04 1.00000000e+00 3.74264571e+01 -6.21675354e+00]', '[ 1.17480000e+04 1.00000000e+00 3.74264571e+01 -6.21675354e+00]', 'None', 'None']
- orbit_relative_number :
- ['None', 'None', '9915', '9915', 'None', 'None']
- doppler_rate_coeffs :
- ['None', 'None', '[-5.58027093e+03 1.34212242e+06 -3.22798340e+08 7.76370140e+10]', '[-5.58027093e+03 1.34212242e+06 -3.22798340e+08 7.76370140e+10]', 'None', 'None']
- incidence_center :
- ['None', 'None', '29.5', '30.5', 'None', 'None']
- grsr_poly_order :
- ['None', 'None', '4', '4', 'None', 'None']
- velY :
- ['None', 'None', '[-874.61792057 -874.43891918 -874.25989712 -874.08085523 -873.90179267\n -873.7227103 -873.54360769 -873.36448441 -873.18534133 -873.0061776\n -872.82699406 -872.6477903 -872.4685659 -872.2893217 -872.11005687\n -871.93077225 -871.75146742 -871.57214196 -871.39279673 -871.21343086\n -871.03404523 -870.85463941 -870.67521297 -870.49576677 -870.31629996\n -870.1368134 -869.95730666 -869.77777932 -869.59823223 -869.41866455\n -869.23907713 -869.05946955 -868.87984138 -868.70019348 -868.520525\n -868.3408368 -868.16112845 -867.98139953 -867.8016509 -867.6218817\n -867.44209279 -867.26228376 -867.08245416 -866.90260487 -866.72273502\n -866.54284549 -866.36293584 -866.18300565 -866.00305577 -865.82308536\n -865.64309527 -865.46308508 -865.28305437 -865.10300399 -864.92293308\n -864.74284252 -864.56273187 -864.38260071 -864.2024499 -864.02227858\n -863.84208762 -863.66187659 -863.48164506 -863.30139389 -863.12112223\n -862.94083095 -862.76051961 -862.58018779 -862.39983634 -862.21946442\n -862.03907289 -861.85866132 -861.67822928 -861.49777764 -861.31730553\n -861.13681383 -860.9563021 -860.77576992 -860.59521816 -860.41464594\n -860.23405415]', '[-874.61792057 -874.43891918 -874.25989712 -874.08085523 -873.90179267\n -873.7227103 -873.54360769 -873.36448441 -873.18534133 -873.0061776\n -872.82699406 -872.6477903 -872.4685659 -872.2893217 -872.11005687\n -871.93077225 -871.75146742 -871.57214196 -871.39279673 -871.21343086\n -871.03404523 -870.85463941 -870.67521297 -870.49576677 -870.31629996\n -870.1368134 -869.95730666 -869.77777932 -869.59823223 -869.41866455\n -869.23907713 -869.05946955 -868.87984138 -868.70019348 -868.520525\n -868.3408368 -868.16112845 -867.98139953 -867.8016509 -867.6218817\n -867.44209279 -867.26228376 -867.08245416 -866.90260487 -866.72273502\n -866.54284549 -866.36293584 -866.18300565 -866.00305577 -865.82308536\n -865.64309527 -865.46308508 -865.28305437 -865.10300399 -864.92293308\n -864.74284252 -864.56273187 -864.38260071 -864.2024499 -864.02227858\n -863.84208762 -863.66187659 -863.48164506 -863.30139389 -863.12112223\n -862.94083095 -862.76051961 -862.58018779 -862.39983634 -862.21946442\n -862.03907289 -861.85866132 -861.67822928 -861.49777764 -861.31730553\n -861.13681383 -860.9563021 -860.77576992 -860.59521816 -860.41464594\n -860.23405415]', 'None', 'None']
- doppler_rate_poly_order :
- ['None', 'None', '3', '3', 'None', 'None']
- look_side :
- ['None', 'None', 'right', 'right', 'None', 'None']
- coord_first_near :
- ['None', 'None', '[ 1. 1. 37.41700285 -6.2818332 ]', '[ 1. 1. 37.41700285 -6.2818332 ]', 'None', 'None']
- slant_range_to_first_pixel :
- ['None', 'None', '621685.2427500114', '621685.2427500114', 'None', 'None']
- acquisition_prf :
- ['None', 'None', '5886.672581404736', '5886.672581404736', 'None', 'None']
- chirp_bandwidth :
- ['None', 'None', '300000000.0', '300000000.0', 'None', 'None']
- orbit_processing_level :
- ['None', 'None', 'precise', 'precise', 'None', 'None']
- dc_estimate_coeffs :
- ['None', 'None', '[[-2259.75195312 0. 0. 0. ]\n [-1743.7265625 0. 0. 0. ]\n [-1227.69921875 0. 0. 0. ]\n [ -711.671875 0. 0. 0. ]\n [ -195.64453125 0. 0. 0. ]\n [ 320.38085938 0. 0. 0. ]\n [ 836.40625 0. 0. 0. ]\n [ 1352.43359375 0. 0. 0. ]\n [ 1868.4609375 0. 0. 0. ]\n [ 2384.48828125 0. 0. 0. ]]', '[[-2259.75195312 0. 0. 0. ]\n [-1743.7265625 0. 0. 0. ]\n [-1227.69921875 0. 0. 0. ]\n [ -711.671875 0. 0. 0. ]\n [ -195.64453125 0. 0. 0. ]\n [ 320.38085938 0. 0. 0. ]\n [ 836.40625 0. 0. 0. ]\n [ 1352.43359375 0. 0. 0. ]\n [ 1868.4609375 0. 0. 0. ]\n [ 2384.48828125 0. 0. 0. ]]', 'None', 'None']
- window_function_range :
- ['None', 'None', 'TAYLOR_20_4', 'TAYLOR_20_4', 'None', 'None']
- orbit_direction :
- ['None', 'None', 'DESCENDING', 'ASCENDING', 'None', 'None']
- avg_scene_height :
- ['None', 'None', '110.74176', '110.74176', 'None', 'None']
- coord_center :
- ['None', 'None', '[5875. 5389. 37.44561785 -6.25418761]', '[5875. 5389. 37.44561785 -6.25418761]', 'None', 'None']
- orbit_repeat_cycle :
- ['None', 'None', '99999', '99999', 'None', 'None']
- zerodoppler_start_utc :
- ['None', 'None', '2021-04-27T21:51:27.093679', '2021-04-27T21:51:27.093679', 'None', 'None']
- dc_estimate_time_utc :
- ['None', 'None', "['2021-04-27T21:51:27.093640' '2021-04-27T21:51:27.178412'\n '2021-04-27T21:51:27.263185' '2021-04-27T21:51:27.347958'\n '2021-04-27T21:51:27.432730' '2021-04-27T21:51:27.517503'\n '2021-04-27T21:51:27.602275' '2021-04-27T21:51:27.687048'\n '2021-04-27T21:51:27.771820' '2021-04-27T21:51:27.856593']", "['2021-04-27T21:51:27.093640' '2021-04-27T21:51:27.178412'\n '2021-04-27T21:51:27.263185' '2021-04-27T21:51:27.347958'\n '2021-04-27T21:51:27.432730' '2021-04-27T21:51:27.517503'\n '2021-04-27T21:51:27.602275' '2021-04-27T21:51:27.687048'\n '2021-04-27T21:51:27.771820' '2021-04-27T21:51:27.856593']", 'None', 'None']
- polarization :
- ['None', 'None', 'VV', 'VV', 'None', 'None']
- dc_estimate_poly_order :
- ['None', 'None', '3', '3', 'None', 'None']
- coord_last_far :
- ['None', 'None', '[ 1.17480000e+04 1.07790000e+04 3.74741096e+01 -6.22731201e+00]', '[ 1.17480000e+04 1.07790000e+04 3.74741096e+01 -6.22731201e+00]', 'None', 'None']
- posY :
- ['None', 'None', '[-921374.0111596 -921461.46392007 -921548.89898784 -921636.31594396\n -921723.71520326 -921811.09634695 -921898.45958141 -921985.80511285\n -922073.13252274 -922160.44222547 -922247.73380269 -922335.00746057\n -922422.26340509 -922509.50121817 -922596.72131376 -922683.92327395\n -922771.10730469 -922858.27361175 -922945.42177747 -923032.55221539\n -923119.66450801 -923206.75886107 -923293.83548014 -923380.89394799\n -923467.93467772 -923554.95725228 -923641.96187719 -923728.94875781\n -923815.91747734 -923902.86844845 -923989.80125452 -924076.71610086\n -924163.61319261 -924250.49211339 -924337.35327547 -924424.19626264\n -924511.02128001 -924597.82853249 -924684.61760415 -924771.38890681\n -924858.1420247 -924944.8771627 -925031.59452554 -925118.2936977\n -925204.97509058 -925291.63828885 -925378.28349717 -925464.91092006\n -925551.52014242 -925638.11157524 -925724.6848036 -925811.24003196\n -925897.77746461 -925984.2966869 -926070.79810938 -926157.28131758\n -926243.74651573 -926330.19390792 -926416.62307992 -926503.03444186\n -926589.42757968 -926675.80269742 -926762.15999894 -926848.49907045\n -926934.82032164 -927021.1233389 -927107.40832605 -927193.67548674\n -927279.92440761 -927366.15549791 -927452.36834447 -927538.56315089\n -927624.7401206 -927710.89884068 -927797.03971997 -927883.16234572\n -927969.26692131 -928055.35364997 -928141.4221192 -928227.47273742\n -928313.50509229]', '[-921374.0111596 -921461.46392007 -921548.89898784 -921636.31594396\n -921723.71520326 -921811.09634695 -921898.45958141 -921985.80511285\n -922073.13252274 -922160.44222547 -922247.73380269 -922335.00746057\n -922422.26340509 -922509.50121817 -922596.72131376 -922683.92327395\n -922771.10730469 -922858.27361175 -922945.42177747 -923032.55221539\n -923119.66450801 -923206.75886107 -923293.83548014 -923380.89394799\n -923467.93467772 -923554.95725228 -923641.96187719 -923728.94875781\n -923815.91747734 -923902.86844845 -923989.80125452 -924076.71610086\n -924163.61319261 -924250.49211339 -924337.35327547 -924424.19626264\n -924511.02128001 -924597.82853249 -924684.61760415 -924771.38890681\n -924858.1420247 -924944.8771627 -925031.59452554 -925118.2936977\n -925204.97509058 -925291.63828885 -925378.28349717 -925464.91092006\n -925551.52014242 -925638.11157524 -925724.6848036 -925811.24003196\n -925897.77746461 -925984.2966869 -926070.79810938 -926157.28131758\n -926243.74651573 -926330.19390792 -926416.62307992 -926503.03444186\n -926589.42757968 -926675.80269742 -926762.15999894 -926848.49907045\n -926934.82032164 -927021.1233389 -927107.40832605 -927193.67548674\n -927279.92440761 -927366.15549791 -927452.36834447 -927538.56315089\n -927624.7401206 -927710.89884068 -927797.03971997 -927883.16234572\n -927969.26692131 -928055.35364997 -928141.4221192 -928227.47273742\n -928313.50509229]', 'None', 'None']
- satellite_look_angle :
- ['None', 'None', '29', '30', 'None', 'None']
- calibration_factor :
- ['None', 'None', '3.939204325311276e-08', '3.939204325311276e-08', 'None', 'None']
- range_looks :
- ['None', 'None', '1', '1', 'None', 'None']
- product_name :
- ['None', 'None', 'ICEYE_GRD_54549_20210427T215124_hollow_10x10pixels_fake_1', 'ICEYE_GRD_54549_20210427T215124_hollow_10x10pixels_fake_0', 'None', 'None']
- grsr_coefficients :
- ['None', 'None', '[ 6.21685243e+05 5.24903202e-01 6.49477815e-07 -5.50559950e-13\n 1.30562747e-19]', '[ 6.21685243e+05 5.24903202e-01 6.49477815e-07 -5.50559950e-13\n 1.30562747e-19]', 'None', 'None']
- chirp_duration :
- ['None', 'None', '3.397714285714286e-05', '3.397714285714286e-05', 'None', 'None']
- satellite_name :
- ['None', 'None', "('ICEYE-XY',)", "('ICEYE-XY',)", 'None', 'None']
- posX :
- ['None', 'None', '[5474808.16271857 5474340.81737572 5473873.4037893 5473405.92419404\n 5472938.37636674 5472470.76254275 5472003.08161336 5471535.33246921\n 5471067.51734663 5470599.6340208 5470131.6847287 5469663.66836081\n 5469195.58380697 5468727.43330512 5468259.21462887 5467790.93001677\n 5467322.57835854 5466854.15854321 5466385.67281031 5465917.11893186\n 5465448.49914802 5464979.81234768 5464511.05741911 5464042.23660344\n 5463573.34767109 5463104.39286383 5462635.37106976 5462166.28117635\n 5461697.12542633 5461227.90158851 5460758.61190628 5460289.25526693\n 5459819.83055714 5459350.34002124 5458880.78142647 5458411.1570178\n 5457941.46568175 5457471.70630418 5457001.88113104 5456531.98792796\n 5456062.02894151 5455592.00305741 5455121.90916075 5454651.74949905\n 5454181.52183638 5453711.2284209 5453240.86813754 5452770.43987059\n 5452299.94586918 5451829.38389577 5451358.75620012 5450888.06166637\n 5450417.29917802 5449946.47098578 5449475.57485055 5449004.61302369\n 5448533.58438853 5448062.48782779 5447591.32559378 5447120.09544579\n 5446648.79963678 5446177.4370493 5445706.00656526 5445234.51043858\n 5444762.94642696 5444291.31678496 5443819.62039435 5443347.85613624\n 5442876.02626614 5442404.12854017 5441932.16521447 5441460.13517001\n 5440988.03728712 5440515.87382291 5440043.64253192 5439571.34567188\n 5439098.98212298 5438626.55076475 5438154.0538559 5437681.48914937\n 5437208.85890448]', '[5474808.16271857 5474340.81737572 5473873.4037893 5473405.92419404\n 5472938.37636674 5472470.76254275 5472003.08161336 5471535.33246921\n 5471067.51734663 5470599.6340208 5470131.6847287 5469663.66836081\n 5469195.58380697 5468727.43330512 5468259.21462887 5467790.93001677\n 5467322.57835854 5466854.15854321 5466385.67281031 5465917.11893186\n 5465448.49914802 5464979.81234768 5464511.05741911 5464042.23660344\n 5463573.34767109 5463104.39286383 5462635.37106976 5462166.28117635\n 5461697.12542633 5461227.90158851 5460758.61190628 5460289.25526693\n 5459819.83055714 5459350.34002124 5458880.78142647 5458411.1570178\n 5457941.46568175 5457471.70630418 5457001.88113104 5456531.98792796\n 5456062.02894151 5455592.00305741 5455121.90916075 5454651.74949905\n 5454181.52183638 5453711.2284209 5453240.86813754 5452770.43987059\n 5452299.94586918 5451829.38389577 5451358.75620012 5450888.06166637\n 5450417.29917802 5449946.47098578 5449475.57485055 5449004.61302369\n 5448533.58438853 5448062.48782779 5447591.32559378 5447120.09544579\n 5446648.79963678 5446177.4370493 5445706.00656526 5445234.51043858\n 5444762.94642696 5444291.31678496 5443819.62039435 5443347.85613624\n 5442876.02626614 5442404.12854017 5441932.16521447 5441460.13517001\n 5440988.03728712 5440515.87382291 5440043.64253192 5439571.34567188\n 5439098.98212298 5438626.55076475 5438154.0538559 5437681.48914937\n 5437208.85890448]', 'None', 'None']
- incidence_angle_ground_range_origin :
- ['None', 'None', '0.0', '0.0', 'None', 'None']
- processing_prf :
- ['None', 'None', '36909.21454162281', '36909.21454162281', 'None', 'None']
- orbit_absolute_number :
- ['None', 'None', '9915', '9915', 'None', 'None']
- range_spacing :
- ['None', 'None', '0.5', '0.5', 'None', 'None']
- velZ :
- ['None', 'None', '[6022.05575618 6021.5578102 6021.05979033 6020.56169896 6020.06353371\n 6019.56529696 6019.06698754 6018.56860427 6018.07014951 6017.57162092\n 6017.07302086 6016.57434815 6016.07560162 6015.57678364 6015.07789185\n 6014.57892863 6014.07989279 6013.58078316 6013.08160211 6012.58234728\n 6012.08302105 6011.58362224 6011.08414966 6010.58460569 6010.08498798\n 6009.58529889 6009.08553725 6008.58570188 6008.08579515 6007.5858147\n 6007.08576292 6006.58563861 6006.08544059 6005.58517126 6005.08482823\n 6004.5844139 6004.08392707 6003.58336657 6003.08273479 6002.58202933\n 6002.08125261 6001.58040342 6001.07948059 6000.5784865 6000.07741878\n 5999.57627981 5999.07506842 5998.57378341 5998.07242718 5997.57099734\n 5997.06949629 5996.56792284 5996.06627581 5995.56455758 5995.06276578\n 5994.5609028 5994.05896746 5993.55695855 5993.05487849 5992.55272489\n 5992.05050013 5991.54820304 5991.04583243 5990.54339068 5990.04087542\n 5989.53828905 5989.03563037 5988.53289819 5988.03009492 5987.52721816\n 5987.02427032 5986.52125021 5986.01815663 5985.51499198 5985.01175388\n 5984.50844473 5984.00506334 5983.50160851 5982.99808264 5982.49448335\n 5981.99081305]', '[6022.05575618 6021.5578102 6021.05979033 6020.56169896 6020.06353371\n 6019.56529696 6019.06698754 6018.56860427 6018.07014951 6017.57162092\n 6017.07302086 6016.57434815 6016.07560162 6015.57678364 6015.07789185\n 6014.57892863 6014.07989279 6013.58078316 6013.08160211 6012.58234728\n 6012.08302105 6011.58362224 6011.08414966 6010.58460569 6010.08498798\n 6009.58529889 6009.08553725 6008.58570188 6008.08579515 6007.5858147\n 6007.08576292 6006.58563861 6006.08544059 6005.58517126 6005.08482823\n 6004.5844139 6004.08392707 6003.58336657 6003.08273479 6002.58202933\n 6002.08125261 6001.58040342 6001.07948059 6000.5784865 6000.07741878\n 5999.57627981 5999.07506842 5998.57378341 5998.07242718 5997.57099734\n 5997.06949629 5996.56792284 5996.06627581 5995.56455758 5995.06276578\n 5994.5609028 5994.05896746 5993.55695855 5993.05487849 5992.55272489\n 5992.05050013 5991.54820304 5991.04583243 5990.54339068 5990.04087542\n 5989.53828905 5989.03563037 5988.53289819 5988.03009492 5987.52721816\n 5987.02427032 5986.52125021 5986.01815663 5985.51499198 5985.01175388\n 5984.50844473 5984.00506334 5983.50160851 5982.99808264 5982.49448335\n 5981.99081305]', 'None', 'None']
- incidence_near :
- ['None', 'None', '31.661727086845776', '31.661727086845776', 'None', 'None']
- azimuth_time_interval :
- ['None', 'None', '7.076784388926729e-05', '7.076784388926729e-05', 'None', 'None']
- product_level :
- ['None', 'None', 'GRD', 'GRD', 'None', 'None']
- processor_version :
- ['None', 'None', 'ICEYE_P_1.31', 'ICEYE_P_1.31', 'None', 'None']
- geo_ref_system :
- ['None', 'None', 'WGS84', 'WGS84', 'None', 'None']
- incidence_angle_coefficients :
- ['None', 'None', '[ 3.16617271e+01 8.74389044e-05 -7.00297508e-11 1.37137269e-18\n 9.45921276e-23]', '[ 3.16617271e+01 8.74389044e-05 -7.00297508e-11 1.37137269e-18\n 9.45921276e-23]', 'None', 'None']
- gcp_terrain_model :
- ['None', 'None', 'DEM', 'DEM', 'None', 'None']
- total_processed_bandwidth_azimuth :
- ['None', 'None', '26363.724672587723', '26363.724672587723', 'None', 'None']
- ant_elev_corr_flag :
- ['None', 'None', '1', '1', 'None', 'None']
- acquisition_start_utc :
- ['None', 'None', '2021-04-27T21:51:24.929476', '2021-04-27T21:51:24.929476', 'None', 'None']
- zerodoppler_end_utc :
- ['None', 'None', '2021-04-27T21:51:27.856415', '2021-04-27T21:51:27.856415', 'None', 'None']
- incidence_far :
- ['None', 'None', '32.172883995845055', '32.172883995845055', 'None', 'None']
- spec_version :
- ['None', 'None', '2.2', '2.2', 'None', 'None']
- range_sampling_rate :
- ['None', 'None', '358148331.2923262', '358148331.2923262', 'None', 'None']
- state_vector_time_utc :
- ['None', 'None', "['2021-04-27T21:51:24.000000' '2021-04-27T21:51:24.100000'\n '2021-04-27T21:51:24.200000' '2021-04-27T21:51:24.300000'\n '2021-04-27T21:51:24.400000' '2021-04-27T21:51:24.500000'\n '2021-04-27T21:51:24.600000' '2021-04-27T21:51:24.700000'\n '2021-04-27T21:51:24.800000' '2021-04-27T21:51:24.900000'\n '2021-04-27T21:51:25.000000' '2021-04-27T21:51:25.100000'\n '2021-04-27T21:51:25.200000' '2021-04-27T21:51:25.300000'\n '2021-04-27T21:51:25.400000' '2021-04-27T21:51:25.500000'\n '2021-04-27T21:51:25.600000' '2021-04-27T21:51:25.700000'\n '2021-04-27T21:51:25.800000' '2021-04-27T21:51:25.900000'\n '2021-04-27T21:51:26.000000' '2021-04-27T21:51:26.100000'\n '2021-04-27T21:51:26.200000' '2021-04-27T21:51:26.300000'\n '2021-04-27T21:51:26.400000' '2021-04-27T21:51:26.500000'\n '2021-04-27T21:51:26.600000' '2021-04-27T21:51:26.700000'\n '2021-04-27T21:51:26.800000' '2021-04-27T21:51:26.900000'\n '2021-04-27T21:51:27.000000' '2021-04-27T21:51:27.100000'\n '2021-04-27T21:51:27.200000' '2021-04-27T21:51:27.300000'\n '2021-04-27T21:51:27.400000' '2021-04-27T21:51:27.500000'\n '2021-04-27T21:51:27.600000' '2021-04-27T21:51:27.700000'\n '2021-04-27T21:51:27.800000' '2021-04-27T21:51:27.900000'\n '2021-04-27T21:51:28.000000' '2021-04-27T21:51:28.100000'\n '2021-04-27T21:51:28.200000' '2021-04-27T21:51:28.300000'\n '2021-04-27T21:51:28.400000' '2021-04-27T21:51:28.500000'\n '2021-04-27T21:51:28.600000' '2021-04-27T21:51:28.700000'\n '2021-04-27T21:51:28.800000' '2021-04-27T21:51:28.900000'\n '2021-04-27T21:51:29.000000' '2021-04-27T21:51:29.100000'\n '2021-04-27T21:51:29.200000' '2021-04-27T21:51:29.300000'\n '2021-04-27T21:51:29.400000' '2021-04-27T21:51:29.500000'\n '2021-04-27T21:51:29.600000' '2021-04-27T21:51:29.700000'\n '2021-04-27T21:51:29.800000' '2021-04-27T21:51:29.900000'\n '2021-04-27T21:51:30.000000' '2021-04-27T21:51:30.100000'\n '2021-04-27T21:51:30.200000' '2021-04-27T21:51:30.300000'\n '2021-04-27T21:51:30.400000' '2021-04-27T21:51:30.500000'\n '2021-04-27T21:51:30.600000' '2021-04-27T21:51:30.700000'\n '2021-04-27T21:51:30.800000' '2021-04-27T21:51:30.900000'\n '2021-04-27T21:51:31.000000' '2021-04-27T21:51:31.100000'\n '2021-04-27T21:51:31.200000' '2021-04-27T21:51:31.300000'\n '2021-04-27T21:51:31.400000' '2021-04-27T21:51:31.500000'\n '2021-04-27T21:51:31.600000' '2021-04-27T21:51:31.700000'\n '2021-04-27T21:51:31.800000' '2021-04-27T21:51:31.900000'\n '2021-04-27T21:51:32.000000']", "['2021-04-27T21:51:24.000000' '2021-04-27T21:51:24.100000'\n '2021-04-27T21:51:24.200000' '2021-04-27T21:51:24.300000'\n '2021-04-27T21:51:24.400000' '2021-04-27T21:51:24.500000'\n '2021-04-27T21:51:24.600000' '2021-04-27T21:51:24.700000'\n '2021-04-27T21:51:24.800000' '2021-04-27T21:51:24.900000'\n '2021-04-27T21:51:25.000000' '2021-04-27T21:51:25.100000'\n '2021-04-27T21:51:25.200000' '2021-04-27T21:51:25.300000'\n '2021-04-27T21:51:25.400000' '2021-04-27T21:51:25.500000'\n '2021-04-27T21:51:25.600000' '2021-04-27T21:51:25.700000'\n '2021-04-27T21:51:25.800000' '2021-04-27T21:51:25.900000'\n '2021-04-27T21:51:26.000000' '2021-04-27T21:51:26.100000'\n '2021-04-27T21:51:26.200000' '2021-04-27T21:51:26.300000'\n '2021-04-27T21:51:26.400000' '2021-04-27T21:51:26.500000'\n '2021-04-27T21:51:26.600000' '2021-04-27T21:51:26.700000'\n '2021-04-27T21:51:26.800000' '2021-04-27T21:51:26.900000'\n '2021-04-27T21:51:27.000000' '2021-04-27T21:51:27.100000'\n '2021-04-27T21:51:27.200000' '2021-04-27T21:51:27.300000'\n '2021-04-27T21:51:27.400000' '2021-04-27T21:51:27.500000'\n '2021-04-27T21:51:27.600000' '2021-04-27T21:51:27.700000'\n '2021-04-27T21:51:27.800000' '2021-04-27T21:51:27.900000'\n '2021-04-27T21:51:28.000000' '2021-04-27T21:51:28.100000'\n '2021-04-27T21:51:28.200000' '2021-04-27T21:51:28.300000'\n '2021-04-27T21:51:28.400000' '2021-04-27T21:51:28.500000'\n '2021-04-27T21:51:28.600000' '2021-04-27T21:51:28.700000'\n '2021-04-27T21:51:28.800000' '2021-04-27T21:51:28.900000'\n '2021-04-27T21:51:29.000000' '2021-04-27T21:51:29.100000'\n '2021-04-27T21:51:29.200000' '2021-04-27T21:51:29.300000'\n '2021-04-27T21:51:29.400000' '2021-04-27T21:51:29.500000'\n '2021-04-27T21:51:29.600000' '2021-04-27T21:51:29.700000'\n '2021-04-27T21:51:29.800000' '2021-04-27T21:51:29.900000'\n '2021-04-27T21:51:30.000000' '2021-04-27T21:51:30.100000'\n '2021-04-27T21:51:30.200000' '2021-04-27T21:51:30.300000'\n '2021-04-27T21:51:30.400000' '2021-04-27T21:51:30.500000'\n '2021-04-27T21:51:30.600000' '2021-04-27T21:51:30.700000'\n '2021-04-27T21:51:30.800000' '2021-04-27T21:51:30.900000'\n '2021-04-27T21:51:31.000000' '2021-04-27T21:51:31.100000'\n '2021-04-27T21:51:31.200000' '2021-04-27T21:51:31.300000'\n '2021-04-27T21:51:31.400000' '2021-04-27T21:51:31.500000'\n '2021-04-27T21:51:31.600000' '2021-04-27T21:51:31.700000'\n '2021-04-27T21:51:31.800000' '2021-04-27T21:51:31.900000'\n '2021-04-27T21:51:32.000000']", 'None', 'None']
- azimuth_looks :
- ['None', 'None', '3', '3', 'None', 'None']
- area_or_point :
- ['None', 'None', 'Area', 'Area', 'None', 'None']
- coord_last_near :
- ['None', 'None', '[ 1.00000000e+00 1.07790000e+04 3.74646332e+01 -6.29258576e+00]', '[ 1.00000000e+00 1.07790000e+04 3.74646332e+01 -6.29258576e+00]', 'None', 'None']
- velX :
- ['None', 'None', '[-4673.12223293 -4673.79355399 -4674.46481748 -4675.13602017\n -4675.80716526 -4676.47824955 -4677.14927463 -4677.82024208\n -4678.49114871 -4679.16199769 -4679.83278583 -4680.50351471\n -4681.17418593 -4681.84479628 -4682.51534894 -4683.18584072\n -4683.85627319 -4684.52664797 -4685.19696183 -4685.86721796\n -4686.53741317 -4687.20754904 -4687.87762716 -4688.54764432\n -4689.21760372 -4689.88750215 -4690.5573412 -4691.22712246\n -4691.89684272 -4692.56650517 -4693.23610662 -4693.90564864\n -4694.57513283 -4695.24455598 -4695.91392128 -4696.58322553\n -4697.25247031 -4697.92165722 -4698.59078306 -4699.259851\n -4699.92885785 -4700.59780519 -4701.26669461 -4701.93552292\n -4702.60429329 -4703.27300253 -4703.94165222 -4704.61024395\n -4705.27877453 -4705.94724712 -4706.61565854 -4707.28401038\n -4707.95230421 -4708.62053684 -4709.28871145 -4709.95682485\n -4710.62487861 -4711.29287433 -4711.96080881 -4712.62868523\n -4713.2965004 -4713.96425589 -4714.6319533 -4715.29958942\n -4715.96716744 -4716.63468417 -4717.30214118 -4717.96954006\n -4718.63687762 -4719.30415703 -4719.97137511 -4720.63853343\n -4721.30563359 -4721.97267238 -4722.63965298 -4723.3065722\n -4723.97343163 -4724.64023284 -4725.30697265 -4725.97365423\n -4726.64027439]', '[-4673.12223293 -4673.79355399 -4674.46481748 -4675.13602017\n -4675.80716526 -4676.47824955 -4677.14927463 -4677.82024208\n -4678.49114871 -4679.16199769 -4679.83278583 -4680.50351471\n -4681.17418593 -4681.84479628 -4682.51534894 -4683.18584072\n -4683.85627319 -4684.52664797 -4685.19696183 -4685.86721796\n -4686.53741317 -4687.20754904 -4687.87762716 -4688.54764432\n -4689.21760372 -4689.88750215 -4690.5573412 -4691.22712246\n -4691.89684272 -4692.56650517 -4693.23610662 -4693.90564864\n -4694.57513283 -4695.24455598 -4695.91392128 -4696.58322553\n -4697.25247031 -4697.92165722 -4698.59078306 -4699.259851\n -4699.92885785 -4700.59780519 -4701.26669461 -4701.93552292\n -4702.60429329 -4703.27300253 -4703.94165222 -4704.61024395\n -4705.27877453 -4705.94724712 -4706.61565854 -4707.28401038\n -4707.95230421 -4708.62053684 -4709.28871145 -4709.95682485\n -4710.62487861 -4711.29287433 -4711.96080881 -4712.62868523\n -4713.2965004 -4713.96425589 -4714.6319533 -4715.29958942\n -4715.96716744 -4716.63468417 -4717.30214118 -4717.96954006\n -4718.63687762 -4719.30415703 -4719.97137511 -4720.63853343\n -4721.30563359 -4721.97267238 -4722.63965298 -4723.3065722\n -4723.97343163 -4724.64023284 -4725.30697265 -4725.97365423\n -4726.64027439]', 'None', 'None']
Array Chunk Bytes 1.17 kiB 200 B Shape (6, 10, 10) (1, 10, 10) Count 10 Tasks 6 Chunks Type uint16 numpy.ndarray - Labels(Band, Azimuth, Range)uint8dask.array<chunksize=(1, 10, 10), meta=np.ndarray>
- product_file :
- ['None', 'None', 'ICEYE_GRD_54549_20210427T215124_hollow_10x10pixels_fake_1.tif', 'ICEYE_GRD_54549_20210427T215124_hollow_10x10pixels_fake_0.tif', 'None', 'None']
Array Chunk Bytes 600 B 100 B Shape (6, 10, 10) (1, 10, 10) Count 10 Tasks 6 Chunks Type uint8 numpy.ndarray
The dataset contains labels and data as np.ndarray
. For the segmentation model we will create an IterableDataset that will be used to slice the datacube in 'Azimuth' and 'Range' direction. That way we can directly map it to a deep learning model.
class Iceye_GRD_Loader(torch.utils.data.IterableDataset):
def __init__(self, list_xrdataset):
super(Iceye_GRD_Loader).__init__()
# Change the following for your application - For the purpose of te demo we are going to concat
# the same dataset along a new dimension, for a real project you are going to work with multiple stacks
# For the example purpose we will work with path of size (6, 4, 4) using xbatcher to slice our
# xarray dataset
concated_dataset = xarray.concat(list_xrdataset, "stack")
self.bgen = xbatcher.BatchGenerator(concated_dataset,
{'stack': 1,
'Band': 6,
'Azimuth': 4,
'Range': 4})
def __iter__(self):
for batch in self.bgen:
# Tensorflow does not accept uint16 as type
yield torch.from_numpy(np.squeeze(batch["Intensity"].values.astype("int32"), axis=None)), torch.from_numpy(np.squeeze(batch["Labels"].values, axis=None)).float()
training_data = Iceye_GRD_Loader([dc.xrdataset for i in range(10)])
# We select a batch size of 2.
train_dataloader = DataLoader(training_data, batch_size=2)
# Display image and label.
train_features, train_labels = next(iter(train_dataloader))
print(f"Feature batch shape: {train_features.size()}")
print(f"Labels batch shape: {train_labels.size()}")
Feature batch shape: torch.Size([2, 6, 4, 4]) Labels batch shape: torch.Size([2, 6, 4, 4])
w = 20
h = 20
fig = plt.figure(figsize=(w, 8))
columns = 5
rows = 1
for i in range(0, columns*rows+1):
img = train_features[0].squeeze()[i]
fig.add_subplot(rows, columns+1, i+1)
plt.imshow(img)
plt.show()
import numpy as np
import matplotlib.pyplot as plt
w = 20
h = 20
fig = plt.figure(figsize=(w, 8))
columns = 5
rows = 1
for i in range(0, columns*rows+1):
img = train_labels[0].squeeze()[i]
fig.add_subplot(rows, columns+1, i+1)
plt.imshow(img)
plt.show()
import torch
from torch.nn import Module
from torch.nn import Sequential
from torch.nn import Conv2d, ReLU
# We build a mini model with tensorflow that will read our images and apply and 1d convolution
class MiniModel(Module):
def __init__(self,):
super(MiniModel, self).__init__()
self.block1 = Sequential(
Conv2d(6, 6, kernel_size=1, padding=0),
ReLU()
)
def forward(self, x):
return self.block1(x)
# Use gpu for training if available else use cpu
device = 'cpu'
# Here is the loss and optimizer definition
model = MiniModel()
criterion = nn.MSELoss()
optimizer = torch.optim.Adam(model.parameters(), lr=0.1)
epochs = 50
for epoch in range(epochs):
for i, (images, masks) in enumerate(train_dataloader, 1):
images = images.to(device)
masks = masks.type(torch.LongTensor)
masks = masks.to(device)
# Forward pass
outputs = model(images.float())
loss = criterion(outputs.float(), masks.float()).float()
# Backward and optimize
optimizer.zero_grad()
loss.sum().backward()
optimizer.step()
if (i) % 20 == 0:
print (f"Epoch [{epoch + 1}/{epochs}], Loss: {loss.sum().item():4f}")
Epoch [1/50], Loss: 5792.898438 Epoch [2/50], Loss: 5018.459473 Epoch [3/50], Loss: 5186.329102 Epoch [4/50], Loss: 5134.431152 Epoch [5/50], Loss: 5135.608887 Epoch [6/50], Loss: 5138.066406 Epoch [7/50], Loss: 5132.810547 Epoch [8/50], Loss: 5131.064941 Epoch [9/50], Loss: 5128.675781 Epoch [10/50], Loss: 5126.311523 Epoch [11/50], Loss: 5124.213379 Epoch [12/50], Loss: 5122.261230 Epoch [13/50], Loss: 5120.495605 Epoch [14/50], Loss: 5118.917480 Epoch [15/50], Loss: 5117.520020 Epoch [16/50], Loss: 5116.307617 Epoch [17/50], Loss: 5115.276855 Epoch [18/50], Loss: 5114.426270 Epoch [19/50], Loss: 5113.753906 Epoch [20/50], Loss: 5113.257812 Epoch [21/50], Loss: 5112.934570 Epoch [22/50], Loss: 5112.781738 Epoch [23/50], Loss: 5112.795410 Epoch [24/50], Loss: 5112.974609 Epoch [25/50], Loss: 5113.313965 Epoch [26/50], Loss: 5113.810547 Epoch [27/50], Loss: 5114.461426 Epoch [28/50], Loss: 5115.263184 Epoch [29/50], Loss: 5116.211426 Epoch [30/50], Loss: 5117.304199 Epoch [31/50], Loss: 5118.536621 Epoch [32/50], Loss: 5119.904785 Epoch [33/50], Loss: 5121.406738 Epoch [34/50], Loss: 5123.037598 Epoch [35/50], Loss: 5124.793945 Epoch [36/50], Loss: 5126.672363 Epoch [37/50], Loss: 5128.668457 Epoch [38/50], Loss: 5130.779785 Epoch [39/50], Loss: 5133.001465 Epoch [40/50], Loss: 5135.331543 Epoch [41/50], Loss: 5137.765137 Epoch [42/50], Loss: 5140.299316 Epoch [43/50], Loss: 5142.929199 Epoch [44/50], Loss: 5145.652832 Epoch [45/50], Loss: 5148.466309 Epoch [46/50], Loss: 5151.365723 Epoch [47/50], Loss: 5154.347656 Epoch [48/50], Loss: 5157.408203 Epoch [49/50], Loss: 5160.545898 Epoch [50/50], Loss: 5163.754883
print("Current model prediction")
w = 20
h = 20
fig = plt.figure(figsize=(w, 8))
columns = 5
rows = 1
for i in range(0, columns*rows+1):
output = outputs[0].squeeze()[i].detach().numpy()
fig.add_subplot(rows, columns+1, i+1)
plt.imshow(output)
plt.show()
print("target prediction")
w = 20
h = 20
fig = plt.figure(figsize=(w, 8))
columns = 5
rows = 1
for i in range(0, columns*rows+1):
mask = masks[0].squeeze()[i].detach().numpy()
fig.add_subplot(rows, columns+1, i+1)
plt.imshow(mask)
plt.show()
Current model prediction
target prediction
hyvää työtä!