-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpragya.py
57 lines (35 loc) · 1.3 KB
/
pragya.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# -*- coding: utf-8 -*-
"""Pragya.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1jnn_fXbMITgg9-SgnYyIKplRPVBw2I3X
**Pragya Currency ML Model **
---
Prerequisites
"""
!pip install tflite-model-maker
"""Import the required packages."""
import os
import numpy as np
import tensorflow as tf
assert tf.__version__.startswith('2')
from tflite_model_maker import configs
from tflite_model_maker import ExportFormat
from tflite_model_maker import image_classifier
from tflite_model_maker import ImageClassifierDataLoader
from tflite_model_maker import model_spec
import matplotlib.pyplot as plt
"""**Get the data path**
Let's get some images to play with this simple end-to-end example.
"""
import keras
image_path = '/content/drive/Shareddrives/Pragya/Final Dataset/Currency'
"""**Step 1.** Load input data specific to an on-device ML app. Split it to training data and testing data."""
data = ImageClassifierDataLoader.from_folder(image_path)
train_data, test_data = data.split(0.99)
"""**Step 2.** Customize the TensorFlow model."""
model = image_classifier.create(train_data)
"""**Step 3.** Evaluate the model."""
loss, accuracy = model.evaluate(test_data)
"""**Step 4.** Export to TensorFlow Lite model."""
model.export(export_dir='.')