change
Browse files- app.py +30 -0
- model.pkl +3 -0
- requirements.txt +1 -0
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: test.ipynb.
|
| 2 |
+
|
| 3 |
+
# %% auto 0
|
| 4 |
+
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'inf', 'classify_img']
|
| 5 |
+
|
| 6 |
+
# %% test.ipynb 2
|
| 7 |
+
from fastai.vision.all import *
|
| 8 |
+
import gradio as gr
|
| 9 |
+
|
| 10 |
+
# %% test.ipynb 4
|
| 11 |
+
learn = load_learner('model.pkl')
|
| 12 |
+
|
| 13 |
+
# %% test.ipynb 5
|
| 14 |
+
categories = ('Art Deco', 'Baroque', 'Classical', 'Craftsman', 'Gothic', 'Renaissance', 'Tudor', 'Victorian')
|
| 15 |
+
|
| 16 |
+
def classify_img(img):
|
| 17 |
+
pred,idx,probs = learn.predict(img)
|
| 18 |
+
# Convert each tensor probability to a float properly
|
| 19 |
+
return dict(zip(categories, map(float, probs)))
|
| 20 |
+
|
| 21 |
+
# %% test.ipynb 8
|
| 22 |
+
# Define Gradio interface
|
| 23 |
+
image = gr.Image(image_mode="RGB", type="pil")
|
| 24 |
+
label = gr.Label()
|
| 25 |
+
examples = ['classical.jpg', 'artdec.jpg', 'victorian.jpeg']
|
| 26 |
+
|
| 27 |
+
inf = gr.Interface(fn=classify_img, inputs=image, outputs=label, examples=examples)
|
| 28 |
+
|
| 29 |
+
# Launch the app
|
| 30 |
+
inf.launch(inline=False)
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d95a869c1fbaf4a59efa27830b83b708baf3e972b790c844ce08e564ce885633
|
| 3 |
+
size 46997310
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
fastai
|