当前位置: 首页 > news >正文

萍乡做网站的公司有哪些襄阳seo推广

萍乡做网站的公司有哪些,襄阳seo推广,电子商务网站建设的核心,建筑网片有几种gradio常用组件 1.gradio程序启动2.写入html相关代码3.文本框4. 回车触发事件5.选择按钮框6.下拉框7.点击按钮8.清空按钮9.监听组件10.输出流11.template 1.gradio程序启动 import gradio as gr def tab():pass with gr.Blocks() as ui:gr.Markdown("# <center>&am…

gradio常用组件

  • 1.gradio程序启动
  • 2.写入html相关代码
  • 3.文本框
  • 4. 回车触发事件
  • 5.选择按钮框
  • 6.下拉框
  • 7.点击按钮
  • 8.清空按钮
  • 9.监听组件
  • 10.输出流
  • 11.template

1.gradio程序启动

import gradio as gr
def tab():pass
with gr.Blocks() as ui:gr.Markdown("# <center>🕵️‍♂️gradio test 🕵️‍♂️</center>")tab()
ui.launch(server_name='127.0.0.1', server_port=8080,show_api=False, debug=True,share=True)

2.写入html相关代码

gr.Markdown("# <center>🕵️‍♂️ Chatglm robot  🕵️‍♂️</center>")

3.文本框

# placeholder:默认提示词
text=gr.Textbox( label='user',placeholder='input question')

4. 回车触发事件

msg = gr.Textbox( label='user',placeholder='input question')
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(bot, chatbot, chatbot)

5.选择按钮框

mode_name= gr.Radio(['小红', '小白', '小胖', '小黑'], label='name', value='小红')

6.下拉框

# value:默认值
# label:组件名称
mode_type= gr.Dropdown(['1','2','3','4'], label='type', value='1')

7.点击按钮

# inputs:输入组件(输入参数),outputs:输出组件(输出参数)
# fn:触发时调用的函数
button = gr.Button("点击")
button.click(fn=update_keys, inputs=[model_key], outputs=prompt_key)

8.清空按钮

text=gr.Textbox( label='user',placeholder='input question')
clear = gr.Button("清除历史记录")
clear.click(lambda: None, None, text, queue=False)

9.监听组件

  • 输入组件变化,输出组件也变化

    import gradio as gr
    def tab():mode_input=gr.Textbox( label='user',placeholder='input question')mode_output =gr.Textbox( label='user',placeholder='input question')# mode_input值改变,mode_output值也会跟着改变# inputs:输入组件(输入参数),outputs:输出组件(输出参数)# fn:触发时调用的函数mode_input.change(fn=lambda x:x, inputs=mode_input, outputs=mode_output)
    with gr.Blocks() as ui:gr.Markdown("# <center>🕵️‍♂️gradio test 🕵️‍♂️</center>")tab()
    ui.launch(server_name='127.0.0.1', server_port=8080,show_api=False, debug=True,share=True)
    
  • 输入组件变化,对应的下拉框显示的值也变化

    # data为pandas文件
    mode_type= gr.Dropdown(types, label='type', value=types[0])
    mode_title = gr.Dropdown(list(data[data['type']==types[0]]['title'].unique()), label='title')
    mode_type.change(fn=lambda x:gr.update(choices=list(data[data['type']==x]['title'].unique())), inputs=mode_type, outputs=mode_title)
    

10.输出流

import time
import gradio as grdef user(user_message, history):return "", history + [[user_message, None]]def bot(history):bot_message = history[-1][0]history[-1][1] = ""for character in bot_message:history[-1][1] += charactertime.sleep(0.05)yield history
def robot_tab():chatbot = gr.Chatbot(label='robot')msg = gr.Textbox( label='user',placeholder='input question')button = gr.Button("generate answer")# then: 监听事件button.click(user, [msg, chatbot], [msg, chatbot], queue=False).then(bot, chatbot, chatbot)clear = gr.Button("清除历史记录")clear.click(lambda: None, None, chatbot, queue=False)with gr.Blocks() as ui:gr.Markdown("# <center>🕵️‍♂️ stream  🕵️‍♂️</center>")robot_tab()
# 使用队列提交数据
ui.queue()
ui.launch(server_name='127.0.0.1', server_port=8080,show_api=False, debug=True,share=True)

11.template

  • 模板:下代码在这个模板的基础下修改即可
    
    import cv2
    import gradio as grdef update(mode_name,mode_age,mode_gender,mode_height):# image = image.convert('RGB')text=f'我叫{mode_name},性别{mode_gender},身高{mode_height},今年{mode_age}岁。'return text# return imagedef prompt_tab():with gr.Column():with gr.Row():image = gr.Image(type='pil', label="Image")with gr.Column():mode_name= gr.Radio(['小红', '小白', '小胖', '小黑'], label='name', value='小红')mode_age = gr.Radio(['18', '30', '40', '50'], label='age', value='18')mode_gender = gr.Radio(['女', '男'], label='gender', value='女')mode_height = gr.Dropdown(['160','165','170','175','180'], value='160', label='height')prompt = gr.Textbox(label="Prompt")button = gr.Button("Personal Information")button.click(fn=update, inputs=[mode_name,mode_age,mode_gender,mode_height], outputs=prompt)def image_analysis(input_image):output_image =input_imagereturn output_imagedef analyze_tab():with gr.Column():with gr.Row():# 创建输入组件input_image = gr.Image(type='numpy', label="Image")with gr.Column():# 创建输出组件# output_image = gr.outputs.Image(type='pil', label="Image")output_image = gr.outputs.Image(type='numpy',label="Image")button = gr.Button("Analyze")button.click(image_analysis, inputs=[input_image], outputs=[output_image])with gr.Blocks() as ui:gr.Markdown("# <center>🕵️‍♂️ gradio project  🕵️‍♂️</center>")with gr.Tab("Prompt"):prompt_tab()with gr.Tab("Analyze"):analyze_tab()ui.launch(server_name='127.0.0.1', server_port=8080,show_api=False, debug=True,share=True)
http://www.ds6.com.cn/news/81448.html

相关文章:

  • 宿迁网站网站建设南宁seo优化公司
  • 山东银汇建设集团网站黑帽seo工具
  • 网站建设三合一英国搜索引擎
  • 怎么做俄语网站杭州百度推广公司有几家
  • 郑州网站建设 郑州网站制作百度账号客服24小时人工电话
  • 黄村做网站哪家好厦门网
  • 长春网站制作招聘信息软文发稿公司
  • 济宁网站建设制作设计企业策划书
  • 做网站需要了解seo优化的优点
  • 怎么做兼职网站吗陕西疫情最新消息
  • 广西网站建设建议网络公司seo教程
  • 网站申请流程爱站网关键词密度查询
  • 浙江省住房和城乡建设厅官方网站国家大事新闻近三天
  • html电影网站模板网站搭建公司哪家好
  • 织梦网站怎么做二级域名2023知名品牌营销案例100例
  • 英文淘宝网站建设app推广代理平台
  • 向搜索引擎提交网站地图深圳网站建设公司官网
  • ifm网站做啥的在哪里找软件开发公司
  • 佛山网站建设公司哪家性价比高最近新闻事件
  • 网站做优化需要哪些后台信息自助建站系统源码
  • 哪个网站做螺丝生意好旅行网站排名前十名
  • wordpress 防站教程网站建设优化的技巧
  • 怎样提升企业网站的访问青岛模板建站
  • 建设银行官方网站首页入口google关键词排名查询
  • 马云做黄页网站时候北京网站建设专业公司
  • jsp电商购物网站开发公司策划推广
  • 中山市饮食网站建设培训公司
  • 有什么方法在淘宝发布网站建设设计东莞seo技术培训
  • 做网站引流到天猫关键词搜索工具app
  • 企业可以做哪些网站有哪些怎么去推广自己的公司