FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
linux-sdk-python/examples/custom/classify.py at master · edgeimpulse/linux-sdk-python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
edgeimpulse
/
linux-sdk-python
Public
Notifications
You must be signed in to change notification settings
Fork
31
Star
57
Code
Issues
0
Pull requests
4
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
linux-sdk-python
/
examples
/
custom
/
classify.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
72 lines (53 loc) · 1.65 KB
Breadcrumbs
linux-sdk-python
/
examples
/
custom
/
classify.py
Copy path
File metadata and controls
72 lines (53 loc) · 1.65 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import
os
import
sys
,
getopt
import
signal
import
time
from
edge_impulse_linux
.
runner
import
ImpulseRunner
import
io
runner
=
None
def
signal_handler
(
sig
,
frame
):
print
(
'Interrupted'
)
if
(
runner
):
runner
.
stop
()
sys
.
exit
(
0
)
signal
.
signal
(
signal
.
SIGINT
,
signal_handler
)
def
help
():
print
(
'python classify.py <path_to_model.eim> <path_to_features.txt>'
)
def
main
(
argv
):
try
:
opts
,
args
=
getopt
.
getopt
(
argv
,
"h"
, [
"--help"
])
except
getopt
.
GetoptError
:
help
()
sys
.
exit
(
2
)
for
opt
,
arg
in
opts
:
if
opt
in
(
'-h'
,
'--help'
):
help
()
sys
.
exit
()
if
len
(
args
)
<=
1
:
help
()
sys
.
exit
(
2
)
model
=
args
[
0
]
features_file
=
io
.
open
(
args
[
1
],
'r'
,
encoding
=
'utf8'
)
features
=
features_file
.
read
().
strip
().
split
(
","
)
if
'0x'
in
features
[
0
]:
features
=
[
float
(
int
(
f
,
16
))
for
f
in
features
]
else
:
features
=
[
float
(
f
)
for
f
in
features
]
dir_path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
modelfile
=
os
.
path
.
join
(
dir_path
,
model
)
print
(
'MODEL: '
+
modelfile
)
runner
=
ImpulseRunner
(
modelfile
)
try
:
model_info
=
runner
.
init
()
# model_info = runner.init(debug=True, timeout=60) # to get debug print out and set longer timeout
print
(
'Loaded runner for "'
+
model_info
[
'project'
][
'owner'
]
+
' / '
+
model_info
[
'project'
][
'name'
]
+
'"'
)
res
=
runner
.
classify
(
features
)
print
(
"classification:"
)
print
(
res
[
"result"
])
print
(
"timing:"
)
print
(
res
[
"timing"
])
finally
:
if
(
runner
):
runner
.
stop
()
if
__name__
==
'__main__'
:
main
(
sys
.
argv
[
1
:])
Back
|
FazBrowse Home
|
New Git URL