File size: 1,059 Bytes
9a3454a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7ae170a
9a3454a
 
 
 
 
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
import skimage
from fastai.vision.all import *

learn = load_learner('resnet50_m0.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 = "Satellite Image Deforestation Classifier"
description = "A deep learning model based on ResNet50 that can classify satellite images into two categories - deforestation (a deforestation event occured in the image) or not_deforestation."
article="<p style='text-align: center'><a href='https://github.com/LucianCotolan/sas-image-deforestification' target='_blank'>Project Github Repository</a></p>"
examples = ['fragment_1.jpg', 'fragment_2.jpg', 'fragment_3.jpg', 'fragment_4.jpg']

interpretation='default'
enable_queue=True

gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(224, 224)),outputs=gr.outputs.Label(),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()