idjotherwise commited on
Commit
ed1efc4
1 Parent(s): ca3813a

update .gitattributes so git lfs will track .pkl files

Browse files
Files changed (4) hide show
  1. 33669.jpg +0 -0
  2. app.py +27 -0
  3. download.jpg +0 -0
  4. requirements.txt +2 -0
33669.jpg ADDED
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ import skimage
4
+
5
+ learn = load_learner("model.pkl")
6
+
7
+ def is_cat(x):
8
+ return x[0].isupper()
9
+
10
+ labels = learn.dls.vocab
11
+
12
+ def predict(img):
13
+ img = PILImage.create(img)
14
+ pred, pred_idx, probs = learn.predict(img)
15
+ names=["Dog", "Cat"]
16
+ return {names[labels[i]]: float(probs[i]) for i in range(len(labels))}
17
+
18
+ iface = gr.Interface(
19
+ fn=predict,
20
+ inputs=gr.Image(shape=(512, 512)),
21
+ outputs=gr.Label(num_top_classes=2, label="Is it a cat?"),
22
+ title="Is it a cat or a dog?!",
23
+ description="An app to classify whether it is a cat or a dog. The model is trained on the Oxford Pets dataset with fastai.",
24
+ examples=["download.jpg", "33669.jpg"],
25
+ interpretation="default",
26
+ )
27
+ iface.launch(enable_queue=True)
download.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastapi
2
+ scikit-image