tilents
user complete1
869c384
raw
history blame contribute delete
882 Bytes
from abc import ABC
import gradio as gr
class CustomBlocks(gr.Blocks):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# 在这里可以添加自定义的初始化代码
def custom_action(self):
# 在这里可以添加自定义的按钮点击行为
print("Custom button clicked!")
class CustomButton(gr.Button):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# 在这里可以添加自定义的初始化代码
def custom_action(self):
# 在这里可以添加自定义的按钮点击行为
print("Custom button clicked!")
# 创建 Gradio 接口
import gradio as gr
def image_classifier(inp):
return {'cat': 0.3, 'dog': 0.7}
with CustomBlocks() as demo:
custom_button = CustomButton("Custom Button")
# 启动 Gradio 界面
demo.launch()