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

sleap-export can't not unrag #1512

Open
jkbhagatio opened this issue Sep 21, 2023 · 3 comments
Open

sleap-export can't not unrag #1512

jkbhagatio opened this issue Sep 21, 2023 · 3 comments
Labels
bug Something isn't working fixed in future release Fix or feature is merged into develop and will be available in future release.

Comments

@jkbhagatio
Copy link

When trying to use --unrag False with sleap-export, the output is still an unragged export. Using SLEAP v 1.3.1

@talmo
Copy link
Collaborator

talmo commented Sep 22, 2023

Hi @jkbhagatio,

So to be clear: you want the outputs as ragged tensors so you can deal with having variable number of instances yourself?

How are you checking whether the outputs are ragged? Typically TensorFlow will return concrete tensors if everything in the batch is the same size and doesn't need to be ragged, so you may need an example batch that has variable length for you to see those.

Alternatively, even with unragging, you can simply discard instances that are all nans since that's how we deal with variable shapes when unrag=True.

I can't see where the issue could be happening though... Here's where we parse the CLI flag. And here's where we do the model export -- note the logic for unragging:

        full_model = tf.function(
            lambda x: sleap.nn.data.utils.unrag_example(model(x), numpy=False)
            if unrag_outputs
            else model(x)
        )

Let us know how you're running the exported model and what kinds of messages you're seeing there!

Cheers,

Talmo

@jkbhagatio
Copy link
Author

So to be clear: you want the outputs as ragged tensors so you can deal with having variable number of instances yourself?

Hey @talmo, I actually wanted to play with using a ragged tensor output in Bonsai, but this would be nice also.

How are you checking whether the outputs are ragged?

I noticed that in the output of sleap-export, the Args were reported as 'unrag': True even if I used the --unrag False flag. And the size of the exported exported pbs were the same, with and without using the --unrag False flag.

Let me know if you think I'm doing something silly, or what else I can try to help debug this!

@roomrys roomrys added fixed in future release Fix or feature is merged into develop and will be available in future release. bug Something isn't working labels Oct 11, 2023
@roomrys
Copy link
Collaborator

roomrys commented Oct 11, 2023

Hi @jkbhagatio,

You are totally correct, there was some illogical logic here. We were using a different action for the --unrag argument (namely "store_true") which sets args.unrag to True when --unrag is included in the command which makes sense for the naming. But! we also set the default to True since this is the behavior we want as the default, but this means that omitting --unrag still sets args.unrag to True, i.e. no way to set it to False.

Seeing as --unrag was totally a dud argument, I removed it and instead replaced it with the --ragged argument which sets args.ragged to False by default (if omitted) and args.ragged to True if included in the command. This way the default is still to unrag, but the command/arguments work as expected.

Thanks.,
Liezl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in future release Fix or feature is merged into develop and will be available in future release.
Projects
None yet
Development

No branches or pull requests

3 participants