Spaces:
Sleeping
Sleeping
File size: 853 Bytes
5015978 c8b0511 5015978 c8b0511 5015978 c8b0511 5015978 c8b0511 5015978 83acea6 c8b0511 5015978 c8b0511 5015978 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import gradio as gr
import numpy as np
import random
# 模擬辨識按鈕的回傳邏輯
def fake_detect(image):
# 隨機回傳 "yap" 或 "not"
result = random.choice(["yap", "not"])
return image, result
# 建立 Gradio 介面
with gr.Blocks() as demo:
gr.Markdown("## 🦺 Helmet ")
gr.Markdown("請上傳一張圖片,然後點擊「辨識」按鈕模擬結果展示")
with gr.Row():
with gr.Column():
image_input = gr.Image(type="numpy", label="上傳圖片")
detect_button = gr.Button("辨識")
with gr.Column():
image_output = gr.Image(type="numpy", label="推論結果")
result_label = gr.Textbox(label="辨識摘要", placeholder="結果")
detect_button.click(fn=fake_detect, inputs=image_input, outputs=[image_output, result_label])
demo.launch() |