File size: 1,156 Bytes
4a1f11f
08b90ae
 
4a1f11f
08b90ae
 
 
 
 
 
655a404
08b90ae
 
 
 
 
 
4a1f11f
08b90ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bcc3395
08b90ae
 
bcc3395
08b90ae
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
40
41
42
43
44
45
46
47
48
49
50
import gradio as gr
from fastai.vision.all import *
import os

def is_cat(x):
    if x[0].isupper():
        return 'cat'
    else:
        return 'dog'
    
learn_inference = load_learner('is_Cat_resnet.pkl')


    
def image_mod(image):
    detect, _, predict =  learn_inference.predict(image)
    return detect

image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
examples=[
        "images/db.jpg",
        "images/dog2.jpg",
        "images/cat3.jpg",
        "images/dog4.jpg",
        "images/pug1.jpg",
        "images/cat2.jpg",
    ]

# examples=[
#         os.path.join(os.path.dirname(__file__), "images/db.jpg"),
#         os.path.join(os.path.dirname(__file__), "images/dog1.jpg"),
#         os.path.join(os.path.dirname(__file__), "images/dog2.jpg"),
#         os.path.join(os.path.dirname(__file__), "images/dog3.jpg"),
#         os.path.join(os.path.dirname(__file__), "images/dog4.jpg"),
#         os.path.join(os.path.dirname(__file__), "images/pug1.jpg"),
#     ]


demo = gr.Interface(
    image_mod,
    inputs = image,
    outputs = label,
    examples = examples
    
)

if __name__ == "__main__":
    demo.launch()