my_roject / cbc_encryption.py
Godfrey123's picture
Upload cbc_encryption.py
bf80642 verified
# -*- coding: utf-8 -*-
"""car 4ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1DXku3LecVZkncfgprvC10z3cbVXU2Tvr
"""
#hide
! [ -e /content ] && pip install -Uqq fastbook
import fastbook
fastbook.setup_book()
from fastbook import *
from fastai.vision.all import *
from fastai.vision.widgets import *
path = Path('/content/gdrive/MyDrive/cars 4')
dblock = DataBlock(blocks = (ImageBlock, CategoryBlock),
get_items=get_image_files,
splitter=RandomSplitter(seed=42),
get_y=parent_label,
item_tfms=Resize(460),
batch_tfms=aug_transforms(size=224, min_scale=0.75))
dls = dblock.dataloaders(path)
dls.show_batch(max_n=15)
learn = vision_learner(dls, resnet50, metrics=accuracy)
learn.fine_tune(200)
learn.export()
!pip install gradio
from fastai.vision.all import *
import gradio as gr
import skimage
learn_inf = load_learner('export.pkl')
labels = learn_inf.dls.vocab
def predict(img):
img = PILImage.create(img)
pred,pred_idx,probs = learn_inf.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
gr.Interface(fn=predict, inputs=gr.Image(), outputs=gr.Label(num_top_classes=3), title = "cars identifier",
description = "cars identifier" ).launch(share=True)