Spaces:
Runtime error
Runtime error
prateekvyas1996
commited on
Commit
•
9914748
1
Parent(s):
e529f78
Add application file
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
|
6 |
+
learn = load_learner('model.pkl')
|
7 |
+
categories = ('granite', 'diorite', 'andacite', 'komatiites', 'gabbro')
|
8 |
+
|
9 |
+
def classify_image(img):
|
10 |
+
pred,idx,probs = learn.predict(img)
|
11 |
+
return dict(zip(categories, map(float,probs)))
|
12 |
+
|
13 |
+
image = gr.inputs.Image(shape=(250,250))
|
14 |
+
label = gr.outputs.Label()
|
15 |
+
examples = ['granite_test.jpg', 'komitiites_test.jpg']
|
16 |
+
|
17 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
18 |
+
intf.launch(inline=False)
|