File size: 905 Bytes
37a9948
 
9a78075
37a9948
 
9a78075
 
d747e07
9a78075
093029d
 
 
 
 
 
04e302f
 
37a9948
 
 
9aaa512
37a9948
 
 
2921be7
37a9948
6b048eb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import gradio as gr
from fastai.vision.all import *
from fastcore.all import *
import skimage

import io
import pandas as pd
df = pd.read_csv('citytempdata.csv')

def tempfromPath(input_Path):
    a = parent_label(input_Path)
    #print(a)
    b = float(df[df['Capital']==a]['Temperature (degC)'])
    return b

learn = load_learner('P1_model_v2.pkl')

def predict(img):
        img = PILImage.create(img)
        Temp = learn.predict(img)
        return f"""Mean temperature is {round(Temp[0][0],1)} degrees celsius."""
    
title = "City Temperature Estimater"
description = "A fastai model trained on aerial views of cities in order to estimate their mean annual temperatures."
examples = ['Brisbane_aerial_view.jpg','NewYork_aerial_view.jpg']

gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512,512)),outputs=gr.outputs.Textbox(),title=title,description=description,examples=examples).launch()