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 ContfromPath(input_Path): a = parent_label(input_Path) #print(a) b = (df[df['Capital']==a]['Continent']) return b learn = load_learner('P2_model_v1.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 = "City to Continent Finder" description = "A fastai model trained on aerial views of cities in order to estimate which continent they are located in." examples = ['Brisbane_aerial_view.jpg','NewYork_aerial_view.jpg','Yakutsk_aerial_view.jpg','LasVegas_aerial_view.jpg','Darwin_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()