-
Notifications
You must be signed in to change notification settings - Fork 0
/
train.py
47 lines (25 loc) · 1.01 KB
/
train.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
import numpy as np
import os
from tflite_model_maker.config import ExportFormat, QuantizationConfig
from tflite_model_maker import model_spec
from tflite_model_maker import object_detector
from tflite_support import metadata
import tensorflow as tf
assert tf.__version__.startswith('2')
tf.get_logger().setLevel('ERROR')
from absl import logging
logging.set_verbosity(logging.ERROR)
train_data = object_detector.DataLoader.from_pascal_voc(
'iot_project/train',
'iot_project/train',
['pothole', 'speed-breaker', 'obstruction']
)
val_data = object_detector.DataLoader.from_pascal_voc(
'iot_project/validate',
'iot_project/validate',
['pothole', 'speed-breaker', 'obstruction']
)
spec = model_spec.get('efficientdet_lite0')
model = object_detector.create(train_data, model_spec=spec, batch_size=4, train_whole_model=True, epochs=200, validation_data=val_data)
model.evaluate(val_data)
model.export(export_dir='.', tflite_filename='best.tflite')