tyler cross commited on
Commit
711e417
1 Parent(s): 53f7f13

Added model and interface

Browse files
Files changed (3) hide show
  1. __pycache__/app.cpython-311.pyc +0 -0
  2. app.py +15 -4
  3. export.pkl +3 -0
__pycache__/app.cpython-311.pyc ADDED
Binary file (1.48 kB). View file
 
app.py CHANGED
@@ -1,7 +1,18 @@
1
  import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from fastai.vision.all import load_learner
3
+ from PIL import Image
4
 
5
+ model = load_learner('./export.pkl')
 
6
 
7
+ def classify_image(img):
8
+ # Convert the image to a format the model expects
9
+ img = Image.fromarray(img.astype('uint8'), 'RGB')
10
+ # Make a prediction
11
+ pred, idx, probs = model.predict(img)
12
+ # Return the result
13
+ return {model.dls.vocab[i]: float(probs[i]) for i in range(len(model.dls.vocab))}
14
+
15
+ demo = gr.Interface(fn=classify_image, inputs="image", outputs="label")
16
+
17
+ if __name__ == "__main__":
18
+ demo.launch()
export.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21d03b139e8d4f7e07eebfe46348fdc1306f89e23b82eaa5a54791ab8007f548
3
+ size 46971454