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

ColorPicker examples not displayed in examples dataset component #1766

Closed
1 task done
freddyaboulton opened this issue Jul 12, 2022 · 0 comments · Fixed by #1779
Closed
1 task done

ColorPicker examples not displayed in examples dataset component #1766

freddyaboulton opened this issue Jul 12, 2022 · 0 comments · Fixed by #1779
Labels
bug Something isn't working svelte Frontend-related issue (JS)

Comments

@freddyaboulton
Copy link
Collaborator

freddyaboulton commented Jul 12, 2022

Describe the bug

When running an app with ColorPicker examples, the example colors are not displayed in the examples dataset/dataframe.

The color is being correctly selected and displayed in the ColorPicker component though, which makes me think the backend logic is sound and it's a problem specific to the Dataset UI component.

Is there an existing issue for this?

  • I have searched the existing issues

Reproduction

Run demo/color_picker/run.py with the following modifications (setting red and blue as example colors)

import gradio as gr
import numpy as np
from PIL import Image, ImageColor



def change_color(icon, color):


    """
    Function that given an icon in .png format changes its color
    Args:
        icon: Icon whose color needs to be changed.
        color: Chosen color with which to edit the input icon.
    Returns:
        edited_image: Edited icon.
    """
    img = icon.convert("LA")
    img = img.convert("RGBA")
    image_np = np.array(icon)
    _, _, _, alpha = image_np.T
    mask = (alpha > 0)
    image_np[..., :-1][mask.T] = ImageColor.getcolor(color, "RGB")
    edited_image = Image.fromarray(image_np)
    return edited_image


inputs = [
        gr.Image(label="icon", type="pil", image_mode="RGBA"),
        gr.ColorPicker(label="color")
    ]
outputs = gr.Image(label="colored icon")

demo = gr.Interface(
    fn=change_color,
    inputs=inputs,
    outputs=outputs,
    examples=[["/Users/freddy/sources/gradio/demo/blocks_inputs/lion.jpg", "#ff0000"],
              ["/Users/freddy/sources/gradio/demo/blocks_inputs/lion.jpg", "#0000FF"]]
)

if __name__ == "__main__":
    demo.launch()

Screenshot

color_picker_color_not_showing_up

Logs

-

System Info

On main

Severity

annoying

@freddyaboulton freddyaboulton added the bug Something isn't working label Jul 12, 2022
@freddyaboulton freddyaboulton changed the title ColorPicker examples not properly rendered in dataset ColorPicker examples not displayed in examples dataset component Jul 12, 2022
@freddyaboulton freddyaboulton added the svelte Frontend-related issue (JS) label Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working svelte Frontend-related issue (JS)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant