microsoft / farmvibes-ai

FarmVibes.AI: Multi-Modal GeoSpatial ML Models for Agriculture and Sustainability

Home Page:https://microsoft.github.io/farmvibes-ai/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistent ndvi_rasters Count and Invalid Argument Issue in count_cycles.onnx

click2cloud-sagarB opened this issue · comments

Dear Farmvibes Team,
I've specified a time_range of two months (Nov 1, 2022, to Dec 31, 2022, or 61 days), however when the spaceeye pipeline runs, it produces 122 ndvi_rasters. Why is this the case?
We are working on the crop_cycles.ipynb notebook, however there is a problem with the count_cycles.onnx creation.In this example,we provide N=61 as we are providing a 2 month time period for the onnx model. However, the process returns the error "INVALID_ARGUMENT : Got invalid dimensions for input: input for the following indices\n index: 1 Got: 122 Expected: 61\n Please fix either the inputs or the model.\n."
After that, we manually input N=122 and create new crop_cycles.onnx model then we obtain the result when the chunk_onnx.compute_onnx task is successfully completed.

Attached to this issue, you will find the log_file for failure.
log file.zip

Hi, @click2cloud-sagarB. I was able to reproduce the scenario you are describing.

For the input time range, the geometry that you are using is covered by two Sentinel-2 tile IDs (44RQN and 44RQP). The image below shows the boundary of both tiles in blue and green. If you look carefully, you will see a tiny orange point in the intersection of both tiles, close to the 25.25 tick in the axis. That is your geometry.

3b52b1b7-41d8-44a9-8cec-cc7612bb000a

In this time range, there are 25 Sentinel-2 products (13 for tile 44RQN and 12 for 44RQP):

date, number of products, list of tile IDs
2022-12-31 	 2 	 ['44RQP', '44RQN']
2022-12-26 	 2 	 ['44RQP', '44RQN']
2022-12-21 	 2 	 ['44RQP', '44RQN']
2022-12-16 	 2 	 ['44RQP', '44RQN']
2022-12-11 	 2 	 ['44RQP', '44RQN']
2022-12-06 	 2 	 ['44RQP', '44RQN']
2022-12-01 	 2 	 ['44RQP', '44RQN']
2022-11-26 	 2 	 ['44RQP', '44RQN']
2022-11-21 	 2 	 ['44RQP', '44RQN']
2022-11-16 	 1 	 ['44RQN']
2022-11-11 	 2 	 ['44RQP', '44RQN']
2022-11-06 	 2 	 ['44RQP', '44RQN']
2022-11-01 	 2 	 ['44RQP', '44RQN']

There is one missing product for tile 44RQP for date 2022-11-16. This might be an issue with PlanetaryComputer from which we retrieve the products.

When downloading and preprocessing the Sentinel-2 tiles, we select a number of them that intersects the input geometry. In your scenario, we ended up selecting all 12 tiles from 44RQP and one single tile for 44RQN (for 2022-11-16).

When running the SpaceEye workflow, FarmVibes runs the interpolation for each set of tile IDs. This yields 61 daily images (one for each date in your time range) per tile ID. That is why you end up with 122 rasters (two for each date).

In this case, we recommend that you ignore all SpaceEye rasters with tile ID 44RQN. They were obtained from the single 44RQN Sentinel-2 product, and should all be very similar. You can do this with:

spaceeye_rasters = run.output["raster"]
filtered_rasters = [r for r in spaceeye_rasters if r.tile_id == "44RQP"]

Thank you, Rafael; your response has cleared up my confusion.

Awesome. I'll close this issue for now. Feel free to reopen it if any other doubt arises.