File size: 1,347 Bytes
ce48bcb
afd824f
 
ce48bcb
d2cc753
afd824f
 
 
 
 
 
 
 
ab06ca4
0987b90
 
 
 
 
 
 
 
afd824f
 
 
452f443
0987b90
 
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
import gradio as gr
from fastai.vision.all import *
import skimage

learn = load_learner('saved_model/model.pkl')

labels = learn.dls.vocab
def predict(img):
    img = PILImage.create(img)
    pred,pred_idx,probs = learn.predict(img)
    return {labels[i]: float(probs[i]) for i in range(len(labels))}


title = "Fastai homework : Ghost type Classifier"
description = "No intent to create a real ghost detector 👻, but will recognize your pet's costumes! More work is needed to create better datasets, but still I enjoyed the exercise.  Image dataset from the web & built with fastai. Created as a demo for Gradio and HuggingFace Spaces. Notebook [here](https://www.kaggle.com/code/mindgspl/ex2-type-of-ghost-image)"
examples = ['ghost_costume.jpg','ghost_symbol.jpg','ghost_real.jpg', 'test.png', 'test2.png','costume1.png', 'symbol.png','not-ghost-ex/other-04.png','not-ghost-ex/other-08.png',
'not-ghost-ex/other-13.png',
'not-ghost-ex/other-19.png',
'not-ghost-ex/other-24.png',
'not-ghost-ex/other-29.png',
'not-ghost-ex/other-34.png',
'not-ghost-ex/other-39.png']
interpretation='default'
enable_queue=True

gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=4),title=title,description=description,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()