12345678910111213141516171819202122232425 |
- #!/usr/bin/env python
- # -*- encoding: utf-8 -*-
- """
- @Contact : liuyuqi.gov@msn.cn
- @Time : 2024/06/04
- @License : Copyright © 2017-2022 liuyuqi. All Rights Reserved.
- @Desc : 实现将图片变为灰度图
- """
- import gradio as gr
- import cv2
- def to_black(image: gr.Image)->gr.Image:
- """ 图片变为灰度 """
- output = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
- return output
- # GUI http://127.0.0.1:7860/
- interface = gr.Interface(fn=to_black, inputs="image", outputs="image", examples=[["test.png"]])
- if __name__=='__main__':
- app,local_url, share_url= interface.launch(inbrowser=True, server_name='0.0.0.0',share=True,
- auth=("admin", "123456"), server_port=8000, show_error=True,
- inbrowser=True, inline=False, validate=False,
- title="图片变为灰度图", description="图片变为灰度图")
|