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

Blocks Slider change() outputs incorrect value on drag #1453

Closed
1 task done
mindwrapped opened this issue Jun 2, 2022 · 6 comments
Closed
1 task done

Blocks Slider change() outputs incorrect value on drag #1453

mindwrapped opened this issue Jun 2, 2022 · 6 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@mindwrapped
Copy link

mindwrapped commented Jun 2, 2022

Describe the bug

If you click and drag on the slider then it will pass an incorrect value to change().

If you only click on the slider then it will pass the correct value to change().

Is there an existing issue for this?

  • I have searched the existing issues

Reproduction

https://huggingface.co/spaces/mindwrapped/blocks-slider-test

Click and drag -> incorrect value (old value, not the current one displayed on the slider)
Click -> correct value (same value as on the slider)

import gradio as gr

def update_value(val):
  return f'Value is set to {val}'

demo = gr.Blocks()

with demo:
  inp = gr.Slider(0, 100, label='Value')
  md = gr.Markdown('Select a value')

  inp.change(fn=update_value, inputs=inp, outputs=md)

demo.launch()

Screenshot

Screen Shot 2022-06-02 at 1 11 00 PM

Logs

From HF Spaces:

Running on local URL:  http://localhost:7860/

To create a public link, set `share=True` in `launch()`.

System Info

Huggingface Spaces
Gradio: 3.0.10

Severity

blocking upgrade to latest gradio version

@mindwrapped mindwrapped added the bug Something isn't working label Jun 2, 2022
@abidlabs abidlabs added this to the 3.1 milestone Jun 2, 2022
@cyyeh
Copy link
Contributor

cyyeh commented Jun 3, 2022

I found this issue happened when it is deployed using Spaces, there's no issue if I run this application locally.

@aliabid94
Copy link
Collaborator

Will fix, thanks for raising this issue!

@dawoodkhan82 dawoodkhan82 modified the milestones: 3.1, 3.x Jul 12, 2022
@freddyaboulton freddyaboulton modified the milestones: 3.x, 3.2 Aug 1, 2022
@abidlabs abidlabs modified the milestones: 3.2, 3.x Aug 18, 2022
@NimaBoscarino
Copy link
Contributor

I'm running into this as well on Gradio 3.3. Here's a notebook to reproduce: https://colab.research.google.com/drive/1JoDcK5R8lcA7Ty4-zlXnQNBwKXdfgRpb?usp=sharing

Same as mentioned above, works fine locally but on Colab + Spaces it's broken.

@abidlabs
Copy link
Member

This should be solved by #2436, so moving to the 4.0 milestone

@abidlabs abidlabs modified the milestones: 3.x, Gradio 4.0 Jan 17, 2023
@abidlabs
Copy link
Member

Special case of #1954, so closing this issue

@axkoenig
Copy link

axkoenig commented Jun 1, 2023

Hi there,
I think the issue still persists when there is some lag introduced inside the update_value function mentioned above.
Consider the below example:

import gradio as gr

def update_value(val):
  import time
  time.sleep(2) # simulate ML model inference
  return f'Value is set to {val}'

demo = gr.Blocks()

with demo:
  inp = gr.Slider(0, 100, label='Value')
  md = gr.Markdown('Select a value')

  inp.change(fn=update_value, inputs=inp, outputs=md)

demo.launch()

If you drag the slider quickly from left to right, you'll end up with the slider evaluating to 1, but its final value is 46.

Screen Shot 2023-06-01 at 16 35 40

I think this is because under the hood the .update() method is called when the slider is starting to be dragged, however not when it is released. Is there a way to call update again once the slider is released?

I'm on the latest gradio version

pip list | grep gradio
gradio                                3.32.0
gradio_client                         0.2.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants