赞
踩
需要导入的库import pathlib
我们知道利用Gradio的文件对象可以通过变量.name返回文件对象的路径供代码直接调用,但是当我们导入的对象为图片的时候,希望UI页面能显示图像出来,这时可以利用gr.image的type属性。
image = gr.Image(type="filepath")
后面可以通过 call(["inference.cmd", image,........])方法直接调用文件对象。如果不加此属性,是无法直接调用这个对象的。当然,如果是文件对象可以利用image.name方法直接调用的。image = gr.File(), call(["inference.cmd", image.name,........]).
同样如果对象为视频的话可以直接显示预览在UI页面,可以直接通过变量名调用。 drivevideo = gr.Video() ,call(["inference.cmd", image, drivevideo,........]),同样可以把视频对象作为一个文件供后面调用,方法同上。gr.File(), drivevideo.name方法调用。
image = gr.Image(type="filepath",label="人脸图片图片", info="Filepath of video/image that contains faces to use")
drivevideo = gr.Video(label="上传驱动视频", info="Filepath of video/drivevideo file to use as raw drivevideo source")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。