Rami commited on
Commit
b15653e
1 Parent(s): 144c523

Upload 2 files

Browse files
Files changed (2) hide show
  1. classifier.py +17 -0
  2. model.pkl +3 -0
classifier.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+ class Classifier:
5
+ def __init__(self, model_path):
6
+ self.learn = load_learner(model_path)
7
+
8
+ def predict(self, image):
9
+ pred, pred_idx, probs = self.learn.predict(image)
10
+ return {self.learn.dls.vocab[i]: float(p) for i, p in enumerate(probs)}
11
+
12
+ image = gr.inputs.Image(shape=(128, 128))
13
+ label = gr.outputs.Label()
14
+ classifer = Classifier(model_path="model.pkl")
15
+
16
+ interface = gr.Interface(fn=classifer.predict, inputs=image, outputs=label)
17
+ interface.launch(inline=False)
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:43a80dc45caff7afac54d1409dff2d8c581481292529c2619b5e752d162b6408
3
+ size 46956267