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

Ensure components can be remounted with their previous data #10192

Merged
merged 271 commits into from
Jan 3, 2025
Merged

Conversation

pngwn
Copy link
Member

@pngwn pngwn commented Dec 13, 2024

As discussed, this PR does the initial work to support only rendering the visible components. It isn't enabled in this PR because of ImageEditor related complications.

I think this will require an ImageEditor refactor, which makes more sense to take care of in the ImageEditor sprint.

So this PR is mostly an internal refactor that we can 'switch on' when the ImageEditor is in the correct shape.

freddyaboulton and others added 30 commits August 2, 2024 12:24
* Tweaks

* Better

* typo

* lint
* changes

* changes

* add changeset

* add changeset

* Ci security tweaks (#9010)

* asd

* asd

* asd

* asd

* asd

* asd

* asd

* asd

* asd

* asd

* asd

* asd

* asd

* asd

* change

* changes

* changes

* changes

* changes

* changes

* changes

---------

Co-authored-by: Ali Abid <[email protected]>
Co-authored-by: gradio-pr-bot <[email protected]>
Co-authored-by: pngwn <[email protected]>
* changes

* changes

* changes

---------

Co-authored-by: Ali Abid <[email protected]>
* changes

* add changeset

* docstring

* change

* client changess

---------

Co-authored-by: gradio-pr-bot <[email protected]>
…preprocessing (#9073)

* audio format

* add changeset

* lint

* docstring

* format

* fix tests

* tweaks

* refactor

* fix

---------

Co-authored-by: gradio-pr-bot <[email protected]>
* Fix code

* Add code

* Add code

* working demo

* hacky video

* Add code for video

* Fixing some code

* clean queieing

* low streaming mode audio

* reworking

* remove console

* Pretty good spot

* Delete unused

* consolidate

* Add progress bar

* Set time limit null

* delete

* Fix then issue

* merge out

* Add code

* clean up

* Remove base64

* Add code

* minor bugs

* End stream

* Fix rerender

* remove unwanted

* Address streaming comments

* Commit file lol

* ;int

* lint backend

* lint

* Fix queue status. Stream_every defined in event

* Fix types

* Add code

* Add code

* Add code

* queue time

* docstring wording

* Fix typo

* add changeset

---------

Co-authored-by: Abubakar Abid <[email protected]>
Co-authored-by: gradio-pr-bot <[email protected]>
* Add code

* add changeset

* lint

* type check

---------

Co-authored-by: gradio-pr-bot <[email protected]>
* hardenning

* Fix code

* add changeset

* Fix tests

* add test fuzzer

* Clean up

* revert

* Fix

* Add code

---------

Co-authored-by: gradio-pr-bot <[email protected]>
Co-authored-by: Abubakar Abid <[email protected]>
* drop support for python 3.8 and 3.9

* add changeset

* format

* changes

* add changeset

* changes

* add changeset

* changes

* 3.10

* string

* tweak

* tweak

* changes

* changes

* format

* more tweaks

* update actions

* website docs build

* fix func tests

* rev req

* test fix

* remove ruff rule for zip strict

---------

Co-authored-by: gradio-pr-bot <[email protected]>
* Raise WasmUnsupportedError for ffmpeg usage on Lite

* add changeset

* add changeset

* Add WasmUnsupportedError in Audio._convert_to_adts

* Add WasmUnsupportedError in processing_utils.audio_to_file

* Fix

* Raise WasmUnsupportedError from processing_utils.audio_from_file

* empty commit

---------

Co-authored-by: gradio-pr-bot <[email protected]>
* video support

* tests and backend changes

* undo main merge

* upload fix

* Revert "undo main merge"

This reverts commit e2a26e6.

* type fixes

* format

* pr fixes

* Update gradio/components/gallery.py

Co-authored-by: Abubakar Abid <[email protected]>

* Update gradio/components/gallery.py

Co-authored-by: Abubakar Abid <[email protected]>

* type fix

* thumbnails

* thumbnail type

* remove thumbnail generation

* add changeset

* test fixes

* test fixes

* python test fix

* python test fixc

* fix

* fix

* story fix

---------

Co-authored-by: Abubakar Abid <[email protected]>
Co-authored-by: gradio-pr-bot <[email protected]>
* fix

* submit logic happens in Blocks

* add changeset

* trigger ci

* trigger ci

* Add code

* Add code

* Fix retrigger refactor

* Add code

---------

Co-authored-by: gradio-pr-bot <[email protected]>
@pngwn pngwn marked this pull request as ready for review December 14, 2024 02:00
@pngwn pngwn changed the title Render visible Only render visible components Dec 14, 2024
@abidlabs abidlabs self-requested a review December 14, 2024 04:19
@abidlabs
Copy link
Member

Taking a look at this now @pngwn but just a thought that this might be a good time to add a demo along the lines #5217 and benchmark that demo before and after this PR, leading to some nice comms around how much faster / less memory-intensive gradio is with this PR

@abidlabs
Copy link
Member

Very very cool @pngwn! I tried a lot of demos and generally everything is working as expected. Only two exceptions:

(1) The ImageEditor does not seem to be saving its state when unrendered and re-rendered. Try with this example:

import gradio as gr

with gr.Blocks() as demo:
    with gr.Tab("Abc"):
        gr.Textbox()
    with gr.Tab("Abc"):
        gr.ImageEditor()

demo.launch()
Screen.Recording.2024-12-16.at.3.54.09.PM.mov

I checked and on main, the ImageEditor state is saved.

(2) The webcam also seems to reset when unrendered and re-rendered. Try running demo/webcam_constraints/run.py.

Screen.Recording.2024-12-16.at.3.52.40.PM.mov

It turns out that the behavior on main is also broken but in a different way. In main, the webcam recording just becomes corrupted when a different tab is selected. The behavior I would expect is that when a different tab is selected, the webcam stops recording but the video recorded up until that point is saved.

@aliabid94
Copy link
Collaborator

Tried to break it with gr.render but everything worked great!

@pngwn pngwn changed the title Only render visible components Ensure components can be remounted with their previous data Dec 31, 2024
Copy link
Member

@abidlabs abidlabs left a comment

Choose a reason for hiding this comment

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

Tested a bunch of demos and everything looks good to me. Agreed let's get this out as part of ImageEditor sprint 👍

@pngwn pngwn merged commit 4fc7fb7 into main Jan 3, 2025
27 checks passed
@pngwn pngwn deleted the render-visible branch January 3, 2025 11:52
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.