ghost_types / app.py
mindset gospel
see all labels
452f443
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()