File size: 1,295 Bytes
08b80c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
33
34
35
36
37
38
39
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
    }