PawMatchAI / breed_detection.py
DawnC's picture
Upload 5 files
08b80c4
raw
history blame
1.3 kB
import gradio as gr
from PIL import Image
def create_detection_tab(predict_fn, example_images):
"""创建品种识别标签页
Args:
predict_fn: 预测函数
example_images: 示例图片路径列表
"""
with gr.TabItem("Breed Detection"):
gr.HTML("<p style='text-align: center;'>Upload a picture of a dog, and the model will predict its breed and provide detailed information!</p>")
gr.HTML("<p style='text-align: center; color: #666; font-size: 0.9em;'>Note: The model's predictions may not always be 100% accurate, and it is recommended to use the results as a reference.</p>")
with gr.Row():
input_image = gr.Image(label="Upload a dog image", type="pil")
output_image = gr.Image(label="Annotated Image")
output = gr.HTML(label="Prediction Results")
initial_state = gr.State()
input_image.change(
predict_fn,
inputs=input_image,
outputs=[output, output_image, initial_state]
)
gr.Examples(
examples=example_images,
inputs=input_image
)
return {
'input_image': input_image,
'output_image': output_image,
'output': output,
'initial_state': initial_state
}