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

Remove interface model info #215

Merged
merged 8 commits into from
Aug 16, 2024

Conversation

thodkatz
Copy link
Collaborator

@thodkatz thodkatz commented Aug 10, 2024

Following up the discussion #213 (review), we have decided that there is no need to maintain an additional abstract layer in tiktorch (ModelInfo) as a bioimage io interface, because tiktorch and ilastik are tightly coupled with bioimage spec and core.

Thus, in this PR, ModelInfo was removed. The information provided by the ModelInfo, now is represented by the actual bioimage io interface, and more specifically the PredictionPipeline that contains all the information needed for shapes, axes, names for input and output tensors.

The PredictionPipeline as the new entity, is exposed both from the client and the server, when we initiate a model session process.

Althoug the plan is to migrate to spec v5, spec v4 (#212 (comment)) with the concept of parameterized and explicit shape inputs, could be still useful as a baseline. Thus I have added some checks to validate the shapes of the incoming tensors based on the valid shapes provided by the v4 of PredictionPipeline. These checks will be also useful for the upcoming PR of checking GPU out-of-memory

- It is useful for tensors to contain the information of the spec id, that corresponds to the bioimage tensor spec, to be aware of valid shapes for both inputs and output
Copy link
Collaborator

@k-dominik k-dominik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see ModelInfo gone. I'm sure this will simplify future developments quite a bit. Also, awesome to see some green tests :)

I had a few comments. I guess in summary there is a lot of code that is concerned with validation of the spec. I have not checked the spec library, but is this where the spec is lacking and you implemented a hardened check?

I also appreciate small details, like adding parameter names which makes things so much easier to read.

tiktorch/converters.py Outdated Show resolved Hide resolved
tiktorch/converters.py Outdated Show resolved Hide resolved
tiktorch/converters.py Outdated Show resolved Hide resolved
proto/inference.proto Outdated Show resolved Hide resolved
tiktorch/server/session/process.py Outdated Show resolved Hide resolved
tiktorch/server/grpc/inference_servicer.py Outdated Show resolved Hide resolved
tiktorch/server/session/process.py Outdated Show resolved Hide resolved
tiktorch/server/session/process.py Show resolved Hide resolved
- Use the class `Sample` to associate xr.DataArray with tensor id coming from the model
- Do the checks only from the client side
- Add checking about axes validity
- Add tests
Copy link
Collaborator

@k-dominik k-dominik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is almost there - my only issue really is holding a reference to prediction pipeline in the model session, which is not really needed for shape validation.

tiktorch/converters.py Outdated Show resolved Hide resolved
tiktorch/server/session/process.py Outdated Show resolved Hide resolved
tiktorch/server/session/process.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@k-dominik k-dominik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay this looks good. Your changes improved readability for me and it's great that shapes of tensors will now be validated before feeding them through the network :)

return Sample({tensor.tensorId: pb_tensor_to_xarray(tensor) for tensor in pb_tensors})

@classmethod
def from_xr_tensors(cls, tensor_ids: List[str], tensors_data: List[xr.DataArray]):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def from_xr_tensors(cls, tensor_ids: List[str], tensors_data: List[xr.DataArray]):
def from_xr_tensors(cls, tensor_ids: List[str], tensors_data: List[xr.DataArray]) -> Sample:

for completeness

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I have to add pyright in the pre-commit hooks, so we can catch these as well. Thank you for point it out :)

@thodkatz
Copy link
Collaborator Author

Nice! Thank you very much for the review @k-dominik. It was very insightful :)

@thodkatz thodkatz merged commit cdb2c4a into ilastik:main Aug 16, 2024
5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants