updates
Browse files- app.py +19 -4
- banana.jpg +0 -0
- black.png +0 -0
- golden.png +0 -0
- labrador.pkl +3 -0
app.py
CHANGED
@@ -1,7 +1,22 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Import libraries
|
2 |
+
from fastai.vision.all import *
|
3 |
import gradio as gr
|
4 |
|
5 |
+
# Load model
|
6 |
+
learn = load_learner('labrador.pkl')
|
7 |
|
8 |
+
# Define categories
|
9 |
+
categories = ('Black', 'Golden')
|
10 |
+
|
11 |
+
# Define function to classify image
|
12 |
+
def classify_image(img):
|
13 |
+
pred, idx, probs = learn.predict(img)
|
14 |
+
return dict(zip(categories, map(float, probs)))
|
15 |
+
|
16 |
+
# Define Gradio interface
|
17 |
+
image = gr.inputs.Image(shape=(192, 192))
|
18 |
+
label = gr.outputs.Label()
|
19 |
+
examples = ['black.jpg', 'golden.jpg', 'banana.jpg']
|
20 |
+
|
21 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
22 |
+
intf.launch(inline=False)
|
banana.jpg
ADDED
black.png
ADDED
golden.png
ADDED
labrador.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:04b03ebc699795f636b18abd4b8ac958abbb6cc520f550b861f0f2aafbb18f19
|
3 |
+
size 46972090
|