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

Option to change DataStream parameters during .submit_data()? #258

Open
ehpor opened this issue Oct 24, 2024 · 6 comments
Open

Option to change DataStream parameters during .submit_data()? #258

ehpor opened this issue Oct 24, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@ehpor
Copy link
Collaborator

ehpor commented Oct 24, 2024

For many services, we want to just submit data, and change DataStream shape and dtype to whatever we are submitting. It would be nice if there is an option in DataStream.submit_data() for that. Something like:

self.images.submit_data(image, match_datastream_parameters=True)

Opinions? @raphaelpclt @lanemeier7

@ehpor ehpor added the enhancement New feature or request label Oct 24, 2024
@raphaelpclt
Copy link
Collaborator

Hmmm I am a bit surprised. That means all the process / experiments / services reading from this datastream must be ready to adapt to a type change?
Do you have a case in mind where you'd want to change type on the fly? For the shape, it's already possible to submit a smaller frame right?

@lanemeier7
Copy link
Collaborator

lanemeier7 commented Oct 24, 2024

Yes, modification of the original data stream size was needed for the accufiz service. It looks like historically the data was transformed and clipped a bit based radius mask resulting a change in the initial data stream which was set by sensor size in the .yml. Or you could imagine a camera with a windowing capability that can be changed on the fly

@ehpor
Copy link
Collaborator Author

ehpor commented Oct 24, 2024

@raphaelpclt I specifically mean, have an argument in .submit_data() that does the following:

# Make sure the data stream has the right size and datatype.
has_correct_parameters = np.allclose(self.images.shape, [self.height, self.width])
if not has_correct_parameters:
self.images.update_parameters('float32', [self.height, self.width], self.NUM_FRAMES_IN_BUFFER)

and also for the dtype.

We've been repeating this piece of code a few times now, and while I originally thought being strict was the way to go, having an opt-in which does this for you, could be useful.

@ehpor
Copy link
Collaborator Author

ehpor commented Oct 24, 2024

@lanemeier7 Indeed we do this for windowing cameras, dOTF intermediate results, etc... Basically anything where the shape is not known in advance and can change on the fly. You still pay a runtime cost when switching dimensions, but unless you're doing that every single frame (which you should not be doing), then it's fine.

@ehpor
Copy link
Collaborator Author

ehpor commented Oct 24, 2024

Or maybe make DataStream::UpdateParameters() bail out quickly when no parameter changes are needed?

Or maybe have a DataStream.match_parameters(data) function that matches the data stream to the shape and dtype of the data? But honestly, I'd prefer a flag in DataStream.submit_data() if we're going that route.

@lanemeier7
Copy link
Collaborator

The flag sounds the cleanest to me, then it won't add any lines of code to the service logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants