File size: 993 Bytes
dfb4951 7a9f34b dfb4951 7a9f34b |
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 29 30 31 32 33 34 35 36 37 38 39 40 |
# -*- 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()
|