File size: 1,084 Bytes
1f14b70
70194b3
 
2a2f560
1f14b70
 
2a2f560
1f40754
2a2f560
 
 
 
 
 
 
abea0a4
beb208e
66524e4
729b213
28e794c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
from fastai.vision.all import *
import skimage
import re



learn = load_learner('rocks-2.pkl')
  
labels = learn.dls.vocab
def predict(img):
    img = PILImage.create(img)
    pred,pred_idx,probs = learn.predict(img)
    return {labels[i]: float(probs[i]) for i in range(len(labels))}

title = "<div style='text-align:center;width:100%;display:flex;flex-direction:column;justify-content:space-evenly'> <div style='color:#ff5a06'> Rock Classifier</div><div style='padding-left:10%;font-size:small'><a href='https://in.linkedin.com/in/amrutha-kp' target='_blank'>Amrutha KP</a></div></div>"
examples = ["basalt.jpeg","coal.jpeg","granite.jpeg", "limestone1.jpg","marble1.jpeg","quartzite.jpeg","sandstone4.jpeg"]
description = "Rock classification using convolutional neural network - prepared for demonstration purposes . The results may not be accurate since the dataset used for training is very small "

gr.Interface(fn=predict, inputs=gr.Image(), outputs=gr.Label(num_top_classes=7),title = title,examples= examples,description=description).launch(share=True)