You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to create an interface with masked image input and prepare some convenience examples, but it looks like Gradio doesn't support it.
import gradio as gr
with gr.Blocks() as demo:
input_gallary = gr.Image(label='Image Input', type='pil', tool='sketch', source="upload")
output_gallary = gr.Gallery(label="Image Result").style()
gr.Examples(
label='Examples',
examples=[{'image' : 'image.png', 'mask' : 'mask.png'}],
fn=lambda x:x,
inputs=[input_gallary],
outputs=[output_gallary],
cache_examples=False, )
demo.launch(share=True)
Error message:
Exception has occurred: ValueError
Cannot process this value as an Image
I also try to hack through gr.Images with customized postprocess() function, but some other unrelated error shows up.
import gradio as gr
class Customized_Image_Block(gr.Image):
def postprocess(self, y):
from gradio import processing_utils
from PIL import Image as _Image
from pathlib import Path
import numpy as np
if y is None:
return None
if isinstance(y, np.ndarray):
return processing_utils.encode_array_to_base64(y)
elif isinstance(y, dict):
return processing_utils.encode_url_or_file_to_base64(y['image'])
elif isinstance(y, _Image.Image):
return processing_utils.encode_pil_to_base64(y)
elif isinstance(y, (str, Path)):
return processing_utils.encode_url_or_file_to_base64(y)
else:
raise ValueError("Cannot process this value as an Image")
with gr.Blocks() as demo:
input_gallary = Customized_Image_Block(label='Image Input', type='pil', tool='sketch', source="upload")
output_gallary = gr.Gallery(label="Image Result").style()
gr.Examples(
label='Examples',
examples=[{'image' : 'image.png', 'mask' : 'mask.png'}],
fn=lambda x:x,
inputs=[input_gallary],
outputs=[output_gallary],
cache_examples=False, )
demo.launch(share=True)
Error message:
Exception has occurred: AttributeError
'Dataset' object has no attribute 'headers'
The text was updated successfully, but these errors were encountered:
I am trying to create an interface with masked image input and prepare some convenience examples, but it looks like Gradio doesn't support it.
Error message:
I also try to hack through
gr.Images
with customizedpostprocess()
function, but some other unrelated error shows up.Error message:
The text was updated successfully, but these errors were encountered: