Spaces:
Sleeping
Sleeping
Add new file
Browse files
app.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
|
| 2 |
+
|
| 3 |
+
# %% auto 0
|
| 4 |
+
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_kaiju']
|
| 5 |
+
|
| 6 |
+
# %% ../app.ipynb 1
|
| 7 |
+
from fastai.vision.all import *
|
| 8 |
+
import gradio as gr
|
| 9 |
+
|
| 10 |
+
# %% ../app.ipynb 12
|
| 11 |
+
learn = load_learner('model.pkl')
|
| 12 |
+
|
| 13 |
+
# %% ../app.ipynb 18
|
| 14 |
+
categories = ['Godzilla', 'King Kong']
|
| 15 |
+
def classify_kaiju(img):
|
| 16 |
+
pred,idx,probs=learn.predict(img)
|
| 17 |
+
return dict(zip(categories, map(float,probs)))
|
| 18 |
+
|
| 19 |
+
# %% ../app.ipynb 20
|
| 20 |
+
image = gr.inputs.Image(shape=(192, 192))
|
| 21 |
+
label = gr.outputs.Label()
|
| 22 |
+
examples = ['Godzilla_1.jpg', 'KingKong_1.jpg', 'Godzilla_2.jpg', 'KingKong_2.jpg']
|
| 23 |
+
|
| 24 |
+
intf = gr.Interface(fn=classify_kaiju, inputs=image, outputs=label, examples=examples)
|
| 25 |
+
intf.launch(inline=False)
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:99740c94b1e09a3cbc2e1f8449d965d5438c552de8e74d171de508a823fbb0e6
|
| 3 |
+
size 46982974
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
fastai
|