Spaces:
Sleeping
Sleeping
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) | |