File size: 633 Bytes
666fd3d
 
 
 
 
856a0f1
666fd3d
 
 
 
 
 
 
7d6d4fb
666fd3d
7d6d4fb
666fd3d
 
 
 
 
94885b9
 
666fd3d
 
 
 
 
94885b9
666fd3d
 
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
import gradio as gr
from PIL import Image
from fastai.vision.all import *

def predict_image(image):
    learner = load_learner('export_2.pkl')
    img = PILImage.create(image)
    pred = learner.predict(img)
    return pred[0]


def create_interface():
    
    image_input = gr.Image()

    output = gr.Text()

    iface = gr.Interface(
        fn=predict_image,
        inputs=image_input,
        outputs=output,
        title="Animal Classifier",
        description="Upload an image to identify the animal class."
    )
    return iface

if __name__ == "__main__":
    iface = create_interface()
    iface.launch(share=True)