mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
scripts/examples: Add regression example.
This commit is contained in:
parent
abe54df3e7
commit
8b1b548ed2
@ -0,0 +1,31 @@
|
||||
# This work is licensed under the MIT license.
|
||||
# Copyright (c) 2013-2024 OpenMV LLC. All rights reserved.
|
||||
# https://github.com/openmv/openmv/blob/master/LICENSE
|
||||
#
|
||||
# TensorFlow Lite Regression Example
|
||||
#
|
||||
# This example shows off running a regression model on the OpenMV Cam.
|
||||
# A regression model takes an input list of numbers and produces an
|
||||
# output list of numbers. You may pass ndarrays arrays to predict()
|
||||
# and you will get a list of the results back.
|
||||
#
|
||||
# Note: The input list of numbers must be the same size as the input
|
||||
# tensor size of the model.
|
||||
|
||||
import ml
|
||||
from ulab import numpy as np
|
||||
|
||||
# The model is built-in on the RT1062. On other OpenMV Cam's with limited flash space please grab
|
||||
# the model from here: https://github.com/openmv/openmv/tree/master/src/lib/tflm/models and
|
||||
# copy it to the OpenMV Cam's file system. E.g. model = ml.Model("force_int_quant.tflite")
|
||||
model = ml.Model("force_int_quant")
|
||||
print(model)
|
||||
|
||||
i = np.array([-3, -1, -2, 5, -2, 10, -1, 9, 0, # noqa
|
||||
2, 0, 9, 1, 10, 2, -1, 3, 5, # noqa
|
||||
3, 9, 3, 9, 6, 2, 6, 7, 5, # noqa
|
||||
10, 6, -1, 7, 4, 7, 8, 5, 7], # noqa
|
||||
dtype=np.int8).reshape(model.input_shape[0]) # noqa
|
||||
|
||||
print(model.predict([i])[0])
|
||||
# Should print 53.78332
|
||||
BIN
src/lib/tflm/models/force_int_quant.tflite
Normal file
BIN
src/lib/tflm/models/force_int_quant.tflite
Normal file
Binary file not shown.
@ -5,3 +5,4 @@ fomo_face_detection.tflite
|
||||
micro_speech.tflite
|
||||
person_detect.tflite
|
||||
person_detect_vela.tflite
|
||||
force_int_quant.tflite
|
||||
|
||||
@ -118,6 +118,7 @@
|
||||
#define IMLIB_ENABLE_TFLM
|
||||
#define IMLIB_ENABLE_TFLM_BUILTIN_FOMO_FACE_DETECTION
|
||||
#define IMLIB_ENABLE_TFLM_BUILTIN_PERSON_DETECT
|
||||
#define IMLIB_ENABLE_TFLM_BUILTIN_FORCE_INT_QUANT
|
||||
#endif
|
||||
|
||||
// Enable FAST (20+ KBs).
|
||||
|
||||
Loading…
Reference in New Issue
Block a user