Godfrey123 commited on
Commit
bf80642
1 Parent(s): a5f9894

Upload cbc_encryption.py

Browse files
Files changed (1) hide show
  1. cbc_encryption.py +53 -0
cbc_encryption.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """car 4ipynb
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1DXku3LecVZkncfgprvC10z3cbVXU2Tvr
8
+ """
9
+
10
+ #hide
11
+ ! [ -e /content ] && pip install -Uqq fastbook
12
+ import fastbook
13
+ fastbook.setup_book()
14
+
15
+ from fastbook import *
16
+ from fastai.vision.all import *
17
+ from fastai.vision.widgets import *
18
+
19
+ path = Path('/content/gdrive/MyDrive/cars 4')
20
+ dblock = DataBlock(blocks = (ImageBlock, CategoryBlock),
21
+ get_items=get_image_files,
22
+ splitter=RandomSplitter(seed=42),
23
+ get_y=parent_label,
24
+ item_tfms=Resize(460),
25
+ batch_tfms=aug_transforms(size=224, min_scale=0.75))
26
+ dls = dblock.dataloaders(path)
27
+
28
+ dls.show_batch(max_n=15)
29
+
30
+ learn = vision_learner(dls, resnet50, metrics=accuracy)
31
+ learn.fine_tune(200)
32
+
33
+ learn.export()
34
+
35
+ !pip install gradio
36
+
37
+
38
+ from fastai.vision.all import *
39
+ import gradio as gr
40
+ import skimage
41
+
42
+
43
+ learn_inf = load_learner('export.pkl')
44
+ labels = learn_inf.dls.vocab
45
+
46
+
47
+ def predict(img):
48
+ img = PILImage.create(img)
49
+ pred,pred_idx,probs = learn_inf.predict(img)
50
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
51
+
52
+ gr.Interface(fn=predict, inputs=gr.Image(), outputs=gr.Label(num_top_classes=3), title = "cars identifier",
53
+ description = "cars identifier" ).launch(share=True)