File size: 943 Bytes
1a87155
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from transformers import pipeline

classifier = pipeline("image-classification", model="XenArcAI/AIRealNet")

def recognize(img):
    results = classifier(img)
    return {r["label"]: round(r["score"], 3) for r in results}

with gr.Blocks() as demo:   # removed theme for compatibility
    gr.Markdown(
        """
        # **XenArcAI**
        # 🖼️ AIRealNet Image Recognition
        Upload an image and let **AIRealNet** identify what's inside.
        """
    )

    with gr.Row():
        with gr.Column():
            inp = gr.Image(type="pil", label="Upload Image")
            btn = gr.Button("Run Recognition")
        with gr.Column():
            out = gr.Label(num_top_classes=2, label="Predictions")

    examples = gr.Examples(
        examples=["examples/cat.jpg", "examples/dog.jpg", "examples/car.jpg"],
        inputs=inp
    )

    btn.click(fn=recognize, inputs=inp, outputs=[out])

demo.launch()