bisoudunord's picture
Upload app.py
cc43537 verified
# -*- coding: utf-8 -*-
"""jet_classifier_2020.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1k58WRaHBA0ndeIlVSDUk9QPywUFZkWPl
##Test
Previously trained model from 2020 (using vgg), testing if it is still deployable. have to upload my Pickle file(fighter_jets_model_3_vgg.pkl) onto this server. might take a bit of time to upload
"""
#|default_exp app
#|export
# importing fastai library
from fastai.vision.all import *
import gradio as gr
import skimage
#|export
learn = load_learner('fighter_jets_model_3_vgg.pkl')
#|export
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))}
"""## Gradio
trying it on gradio
"""
#|export
title = "Moder Fighter Jet Classifier"
description = "Finetuned VGG neural net using less then 50 photos per aircraft"
interpretation = "default"
enable_queue = True
gr.Interface(fn=predict, inputs="image", outputs="label", title=title,description=description).launch(share=True)