Spaces:
Runtime error
Runtime error
app and imgs
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
import skimage
|
| 4 |
+
import gradio as gr
|
| 5 |
+
|
| 6 |
+
learn = load_learner("god-model.pkl")
|
| 7 |
+
|
| 8 |
+
labels = learn.dls.vocab
|
| 9 |
+
def predict(img):
|
| 10 |
+
img = PILImage.create(img)
|
| 11 |
+
pred,pred_idx,probs = learn.predict(img)
|
| 12 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 13 |
+
|
| 14 |
+
title = "God Classifier"
|
| 15 |
+
description = "A Norse/Hindu God Classifier (fastai course exercise)"
|
| 16 |
+
|
| 17 |
+
gr.Interface(fn=predict,
|
| 18 |
+
inputs=gr.inputs.Image(shape=(512, 512)),
|
| 19 |
+
outputs=gr.outputs.Label(num_top_classes=2),
|
| 20 |
+
title=title,
|
| 21 |
+
description=description,
|
| 22 |
+
examples=['hindu.jpg','norse.jpg'],
|
| 23 |
+
interpretation='default',
|
| 24 |
+
enable_queue=True).launch(share=True)
|
hindu.jpg
ADDED
|
norse.jpg
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastai
|
| 2 |
+
scikit-image
|