find_car / app.py
parthb3
let's deploy to huggingface spaces
dfb4951
raw
history blame
993 Bytes
# -*- coding: utf-8 -*-
"""car_year_finder_p2.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1O0_3A82axlMsWaCiXpSv2cM0frscKrsB
"""
#!pip install -Uqq fastai
#!pip install -Uqq gradio
from fastai.vision.all import *
from fastai.vision.widgets import *
import gradio as gr
#learn = load_learner(Path('/content/drive/MyDrive/AI_Models')/'car_year_finder1.pkl')
#im = PILImage.create('/content/drive/MyDrive/tesla.png')
#im.thumbnail((192,192))
#learn.predict(im)
categories = ('before 1960','from 1970 to 1980','from 1990 to 2000', 'from 2020')
learn = load_learner('car_year_finder1.pkl')
def classify_image(img):
pred, idx, probs = learn.predict(img)
return dict(zip(categories,map(float,probs)))
#classify_image(im)
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
#examples = ['tesla.png','model_t.jpg']
intf=gr.Interface(fn=classify_image, inputs=image, outputs=label)
intf.launch()