How to update gr.Image without flickering?

Currently whenever a gr.Image object gets a new image, it turns white temporarily before updating the image. Can we disable that effect? It’s okay if the displayed image stays unchanged for a while but the flickering is distracting. Thanks!

Example code looks like this. Whenever the gen_image method has a large delay, the image turns white temporarily.

import gradio as gr
import numpy as np
import time

def gen_image(x, state):
    return np.zeros((100, 100, 3), dtype=np.uint8) + int(x * 255)

with gr.Blocks() as demo:
    slider = gr.Slider(0, 1, step=0.1)
    img0 = gen_image(0, None)

    img = gr.Image(
        type="numpy", value=img0, height=img0.shape[0], width=img0.shape[1]

    slider.change(gen_image, slider, img, api_name="predict")
if __name__ == "__main__":
1 Like

Thanks for opening this discussion, @lgzhang!

A solution to this issue would be of interest to me as well :]