-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrain.py
36 lines (26 loc) · 986 Bytes
/
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
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(
'freedomtech/train',
'freedomtech/train',
['obstacle', 'checkpoint']
)
val_data = object_detector.DataLoader.from_pascal_voc(
'freedomtech/validate',
'freedomtech/validate',
['obstacle', 'checkpoint']
)
spec = model_spec.get('efficientdet_lite0')
model = object_detector.create(train_data, model_spec=spec, batch_size=4, train_whole_model=True, epochs=50, validation_data=val_data)
result = model.evaluate(val_data)
print("Evaluate result: ", result)
model.export(export_dir='.', tflite_filename='best2.tflite')