本文主要是介绍gr.Image(tool=...) removed in 4.0? gradio.image tool选项没了?,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1、背景
gradio版本3.43.1时候有 tool =Literal['editor', 'select', 'sketch', 'color-sketch'] | None
安装gradio 4版本时候,发现报错了,Image组件没有tool选项了
2、办法步骤
gradio 4以后,gradio没有tool 移到另个组件gradio.ImageEditor
3、代码demo
import gradio as gr
import timedef sleep(im):time.sleep(5)return [im["background"], im["layers"][0], im["layers"][1], im["composite"]]with gr.Blocks() as demo:# im = gr.ImageEditor(# type="pil",# crop_size="1:1",# )im =gr.Sketchpad(type="pil",crop_size="1:1",)with gr.Group():with gr.Row():im_out_1 = gr.Image(type="pil")im_out_2 = gr.Image(type="pil")im_out_3 = gr.Image(type="pil")im_out_4 = gr.Image(type="pil")btn = gr.Button()im.change(sleep, outputs=[im_out_1, im_out_2, im_out_3, im_out_4], inputs=im)if __name__ == "__main__":demo.launch()
这篇关于gr.Image(tool=...) removed in 4.0? gradio.image tool选项没了?的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!