christinapeng commited on
Commit
a2ddc94
·
1 Parent(s): 88e5e8e

penguin puffin classifier

Browse files
Files changed (6) hide show
  1. app.ipynb +24 -0
  2. app.py +16 -4
  3. model.pkl +3 -0
  4. penguin.jpg +0 -0
  5. puffin.jpg +0 -0
  6. razorbill.jpg +0 -0
app.ipynb ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [],
3
+ "metadata": {
4
+ "kernelspec": {
5
+ "display_name": "base",
6
+ "language": "python",
7
+ "name": "python3"
8
+ },
9
+ "language_info": {
10
+ "codemirror_mode": {
11
+ "name": "ipython",
12
+ "version": 3
13
+ },
14
+ "file_extension": ".py",
15
+ "mimetype": "text/x-python",
16
+ "name": "python",
17
+ "nbconvert_exporter": "python",
18
+ "pygments_lexer": "ipython3",
19
+ "version": "3.11.7"
20
+ }
21
+ },
22
+ "nbformat": 4,
23
+ "nbformat_minor": 2
24
+ }
app.py CHANGED
@@ -1,7 +1,19 @@
 
 
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
1
+ __all__ = []
2
+
3
+ from fastai.vision.all import *
4
  import gradio as gr
5
 
6
+ learn = load_learner('model.pkl')
7
+
8
+ categories = ('Penguin', 'Puffin')
9
+
10
+ def classifyImage(img):
11
+ pred, idx, prob = learn.predict(img)
12
+ return dict(zip(categories, map(float, prob)))
13
+
14
+ image = gr.inputs.Image(shape=(192, 192))
15
+ label = gr.outputs.Label()
16
+ examples = ['penguin.jpg', 'puffin.png', 'razorbill.jpg']
17
 
18
+ intf = gr.Interface(fn=classifyImage, inputs=image, outputs=label, examples=examples)
19
+ intf.launch(inline=False)
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a4d85516845e2e08ed9e25d7353cd6b4fc93e345a3355aac58aba800f8155092
3
+ size 46971390
penguin.jpg ADDED
puffin.jpg ADDED
razorbill.jpg ADDED