File size: 887 Bytes
1821972
9e82079
 
1821972
9e82079
1821972
 
 
 
 
 
 
 
 
7b49776
 
077d2c6
1821972
077d2c6
274cc8c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from fastai.vision.all import *
import gradio as gr

learn=load_learner('model.pkl')

categories = ['chimpanzee','gorilla','human', 'orangutan']

def classify_image(img):
  pred,idx,probs = learn.predict(img)
  return dict(zip(categories, map(float,probs)))

image = gr.Image(shape=(192, 192))
lable = gr.Label()
examples = ['chimpanzee.jpg', 'gorilla.jpg', 'human.jpg', 'orangutan.jpg']
description = '''This project is inspired from the first lesson in the fast.ai course. 
Choose an example photo or upload a photo of a Great Ape (Human, Chimpanzee, Gorilla, or Orangutan) to classify the Great Ape. 
The classifier was trained using the fastai library to fine tune a ResNet-18 CNN model to classify Great Apes.'''

intf = gr.Interface(fn=classify_image, inputs=image, outputs=lable, examples=examples, title='Great Apes Classifier', description=description)
intf.launch(inline=False)