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

Issues with patch sizes and MAXIM models #913

Closed
thekevinscott opened this issue Mar 4, 2023 · 2 comments
Closed

Issues with patch sizes and MAXIM models #913

thekevinscott opened this issue Mar 4, 2023 · 2 comments
Assignees

Comments

@thekevinscott
Copy link
Owner

I'm working on integrating new MAXIM models in #842, but running into an issue that I'm not sure is solvable. Pinging @danwexler because I think you're working on the same thing and am curious if you have any feedback.

These MAXIM models have fixed input sizes (more on why below), which requires images be split into patches. For some models, this works fine. For others, it does not.

The models that seem stable when splitting into patches

Deblurring
fixture

result

Dehazing
fixture

result

Deraining
fixture

result

Dehazing Indoor
fixture

result

The models that exhibit artifacting when splitting into patches

Dehazing Outdoor
fixture

result

Low Light Enhancement

fixture

result

Retouching

fixture

result

I'm converting both the original JAX implementation along with the TF versions. (For some reason, the converted TF versions run much faster but perform worse than their JAX counterparts; I don't know why.)

Why the models require fixed input sizes

Both the JAX and TF versions of the models require fixed input sizes when converting to Tensorflow.js. I believe the reason is because both rely on einops functions, which do not support dynamic shapes.

In the case of the TF version, there's open PRs (here and here) to support arbitrary image sizes, but they're not merged yet.

On the JAX side, similar work would have to be done to deprecate the usage of einops.

Open questions

Is there any way to adjust these models to work across images subdivided into patches? I don't think there is.

So the models could be rewritten to support arbitrary image sizes, but that I think will preclude them from being usable in the browser. Which is maybe the best that can be done for now.

@thekevinscott thekevinscott self-assigned this Mar 4, 2023
@thekevinscott
Copy link
Owner Author

This will be resolved in #842.

I was able to convert the Jax model to accept dynamic input shapes.

If and when the TF port's PR for supporting dynamic shapes is merged, I'll try and work on porting those to Tensorflow.js as well.

@danwexler
Copy link
Contributor

danwexler commented Jul 7, 2023 via email

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

No branches or pull requests

2 participants