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 = "
Rock Classifier
Amrutha KP
" 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)